traceur-rb 0.0.2 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (228) hide show
  1. checksums.yaml +8 -8
  2. data/lib/traceur/configuration.rb +1 -1
  3. data/lib/traceur/version.rb +1 -1
  4. data/{vendor/node_modules → node_modules}/.bin/traceur +0 -0
  5. data/{vendor/node_modules → node_modules}/traceur/LICENSE +0 -0
  6. data/{vendor/node_modules → node_modules}/traceur/README.md +0 -0
  7. data/node_modules/traceur/bin/traceur-runtime.js +3420 -0
  8. data/node_modules/traceur/bin/traceur.js +30354 -0
  9. data/{vendor/node_modules → node_modules}/traceur/node_modules/.bin/semver +0 -0
  10. data/node_modules/traceur/node_modules/commander/History.md +256 -0
  11. data/node_modules/traceur/node_modules/commander/LICENSE +22 -0
  12. data/node_modules/traceur/node_modules/commander/Readme.md +342 -0
  13. data/node_modules/traceur/node_modules/commander/index.js +1103 -0
  14. data/node_modules/traceur/node_modules/commander/node_modules/graceful-readlink/.npmignore +3 -0
  15. data/node_modules/traceur/node_modules/commander/node_modules/graceful-readlink/.travis.yml +5 -0
  16. data/node_modules/traceur/node_modules/commander/node_modules/graceful-readlink/LICENSE +22 -0
  17. data/node_modules/traceur/node_modules/commander/node_modules/graceful-readlink/README.md +17 -0
  18. data/node_modules/traceur/node_modules/commander/node_modules/graceful-readlink/index.js +12 -0
  19. data/node_modules/traceur/node_modules/commander/node_modules/graceful-readlink/package.json +48 -0
  20. data/node_modules/traceur/node_modules/commander/package.json +75 -0
  21. data/{vendor/node_modules → node_modules}/traceur/node_modules/glob/LICENSE +0 -0
  22. data/{vendor/node_modules → node_modules}/traceur/node_modules/glob/README.md +0 -0
  23. data/{vendor/node_modules → node_modules}/traceur/node_modules/glob/common.js +0 -0
  24. data/{vendor/node_modules → node_modules}/traceur/node_modules/glob/glob.js +0 -0
  25. data/{vendor/node_modules → node_modules}/traceur/node_modules/glob/node_modules/inflight/.eslintrc +0 -0
  26. data/{vendor/node_modules → node_modules}/traceur/node_modules/glob/node_modules/inflight/LICENSE +0 -0
  27. data/{vendor/node_modules → node_modules}/traceur/node_modules/glob/node_modules/inflight/README.md +0 -0
  28. data/{vendor/node_modules → node_modules}/traceur/node_modules/glob/node_modules/inflight/inflight.js +0 -0
  29. data/{vendor/node_modules → node_modules}/traceur/node_modules/glob/node_modules/inflight/node_modules/wrappy/LICENSE +0 -0
  30. data/{vendor/node_modules → node_modules}/traceur/node_modules/glob/node_modules/inflight/node_modules/wrappy/README.md +0 -0
  31. data/node_modules/traceur/node_modules/glob/node_modules/inflight/node_modules/wrappy/package.json +52 -0
  32. data/{vendor/node_modules → node_modules}/traceur/node_modules/glob/node_modules/inflight/node_modules/wrappy/test/basic.js +0 -0
  33. data/{vendor/node_modules → node_modules}/traceur/node_modules/glob/node_modules/inflight/node_modules/wrappy/wrappy.js +0 -0
  34. data/node_modules/traceur/node_modules/glob/node_modules/inflight/package.json +61 -0
  35. data/{vendor/node_modules → node_modules}/traceur/node_modules/glob/node_modules/inflight/test.js +0 -0
  36. data/{vendor/node_modules → node_modules}/traceur/node_modules/glob/node_modules/inherits/LICENSE +0 -0
  37. data/{vendor/node_modules → node_modules}/traceur/node_modules/glob/node_modules/inherits/README.md +0 -0
  38. data/{vendor/node_modules → node_modules}/traceur/node_modules/glob/node_modules/inherits/inherits.js +0 -0
  39. data/{vendor/node_modules → node_modules}/traceur/node_modules/glob/node_modules/inherits/inherits_browser.js +0 -0
  40. data/node_modules/traceur/node_modules/glob/node_modules/inherits/package.json +50 -0
  41. data/{vendor/node_modules → node_modules}/traceur/node_modules/glob/node_modules/inherits/test.js +0 -0
  42. data/{vendor/node_modules/traceur/node_modules/glob/node_modules/once/node_modules/wrappy → node_modules/traceur/node_modules/glob/node_modules/minimatch}/LICENSE +0 -0
  43. data/{vendor/node_modules → node_modules}/traceur/node_modules/glob/node_modules/minimatch/README.md +0 -0
  44. data/node_modules/traceur/node_modules/glob/node_modules/minimatch/browser.js +1159 -0
  45. data/node_modules/traceur/node_modules/glob/node_modules/minimatch/minimatch.js +912 -0
  46. data/{vendor/node_modules → node_modules}/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/.npmignore +0 -0
  47. data/{vendor/node_modules → node_modules}/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/.travis.yml +0 -0
  48. data/{vendor/node_modules → node_modules}/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/README.md +0 -0
  49. data/{vendor/node_modules → node_modules}/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/example.js +0 -0
  50. data/{vendor/node_modules → node_modules}/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/index.js +0 -0
  51. data/{vendor/node_modules → node_modules}/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/.npmignore +0 -0
  52. data/{vendor/node_modules → node_modules}/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/.travis.yml +0 -0
  53. data/{vendor/node_modules → node_modules}/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/Makefile +0 -0
  54. data/{vendor/node_modules → node_modules}/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/README.md +0 -0
  55. data/{vendor/node_modules → node_modules}/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/example.js +0 -0
  56. data/{vendor/node_modules → node_modules}/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/index.js +0 -0
  57. data/{vendor/node_modules → node_modules}/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/package.json +0 -0
  58. data/{vendor/node_modules → node_modules}/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/test/balanced.js +0 -0
  59. data/{vendor/node_modules → node_modules}/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/.travis.yml +0 -0
  60. data/{vendor/node_modules → node_modules}/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/LICENSE +0 -0
  61. data/{vendor/node_modules → node_modules}/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/README.markdown +0 -0
  62. data/{vendor/node_modules → node_modules}/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/example/map.js +0 -0
  63. data/{vendor/node_modules → node_modules}/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/index.js +0 -0
  64. data/{vendor/node_modules → node_modules}/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/package.json +0 -0
  65. data/{vendor/node_modules → node_modules}/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/test/map.js +0 -0
  66. data/{vendor/node_modules → node_modules}/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/package.json +0 -0
  67. data/{vendor/node_modules → node_modules}/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/bash-comparison.js +0 -0
  68. data/{vendor/node_modules → node_modules}/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/bash-results.txt +0 -0
  69. data/{vendor/node_modules → node_modules}/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/cases.txt +0 -0
  70. data/{vendor/node_modules → node_modules}/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/dollar.js +0 -0
  71. data/{vendor/node_modules → node_modules}/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/empty-option.js +0 -0
  72. data/{vendor/node_modules → node_modules}/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/generate.sh +0 -0
  73. data/{vendor/node_modules → node_modules}/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/negative-increment.js +0 -0
  74. data/{vendor/node_modules → node_modules}/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/nested.js +0 -0
  75. data/{vendor/node_modules → node_modules}/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/order.js +0 -0
  76. data/{vendor/node_modules → node_modules}/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/pad.js +0 -0
  77. data/{vendor/node_modules → node_modules}/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/same-type.js +0 -0
  78. data/{vendor/node_modules → node_modules}/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/sequence.js +0 -0
  79. data/node_modules/traceur/node_modules/glob/node_modules/minimatch/package.json +63 -0
  80. data/node_modules/traceur/node_modules/glob/node_modules/once/LICENSE +15 -0
  81. data/{vendor/node_modules → node_modules}/traceur/node_modules/glob/node_modules/once/README.md +0 -0
  82. data/node_modules/traceur/node_modules/glob/node_modules/once/node_modules/wrappy/LICENSE +15 -0
  83. data/{vendor/node_modules → node_modules}/traceur/node_modules/glob/node_modules/once/node_modules/wrappy/README.md +0 -0
  84. data/node_modules/traceur/node_modules/glob/node_modules/once/node_modules/wrappy/package.json +52 -0
  85. data/{vendor/node_modules → node_modules}/traceur/node_modules/glob/node_modules/once/node_modules/wrappy/test/basic.js +0 -0
  86. data/{vendor/node_modules → node_modules}/traceur/node_modules/glob/node_modules/once/node_modules/wrappy/wrappy.js +0 -0
  87. data/{vendor/node_modules → node_modules}/traceur/node_modules/glob/node_modules/once/once.js +0 -0
  88. data/node_modules/traceur/node_modules/glob/node_modules/once/package.json +60 -0
  89. data/{vendor/node_modules → node_modules}/traceur/node_modules/glob/node_modules/once/test/once.js +0 -0
  90. data/{vendor/node_modules → node_modules}/traceur/node_modules/glob/package.json +0 -0
  91. data/{vendor/node_modules → node_modules}/traceur/node_modules/glob/sync.js +0 -0
  92. data/node_modules/traceur/node_modules/rsvp/CHANGELOG.md +255 -0
  93. data/{vendor/node_modules → node_modules}/traceur/node_modules/rsvp/LICENSE +0 -0
  94. data/node_modules/traceur/node_modules/rsvp/README.md +366 -0
  95. data/node_modules/traceur/node_modules/rsvp/dist/rsvp.js +1597 -0
  96. data/node_modules/traceur/node_modules/rsvp/dist/rsvp.min.js +9 -0
  97. data/node_modules/traceur/node_modules/rsvp/lib/rsvp.js +70 -0
  98. data/node_modules/traceur/node_modules/rsvp/lib/rsvp.umd.js +51 -0
  99. data/{vendor/node_modules → node_modules}/traceur/node_modules/rsvp/lib/rsvp/-internal.js +0 -0
  100. data/node_modules/traceur/node_modules/rsvp/lib/rsvp/all-settled.js +73 -0
  101. data/{vendor/node_modules → node_modules}/traceur/node_modules/rsvp/lib/rsvp/all.js +0 -0
  102. data/node_modules/traceur/node_modules/rsvp/lib/rsvp/asap.js +112 -0
  103. data/{vendor/node_modules → node_modules}/traceur/node_modules/rsvp/lib/rsvp/config.js +0 -0
  104. data/node_modules/traceur/node_modules/rsvp/lib/rsvp/defer.js +45 -0
  105. data/node_modules/traceur/node_modules/rsvp/lib/rsvp/enumerator.js +130 -0
  106. data/node_modules/traceur/node_modules/rsvp/lib/rsvp/events.js +205 -0
  107. data/{vendor/node_modules → node_modules}/traceur/node_modules/rsvp/lib/rsvp/filter.js +0 -0
  108. data/node_modules/traceur/node_modules/rsvp/lib/rsvp/hash-settled.js +126 -0
  109. data/node_modules/traceur/node_modules/rsvp/lib/rsvp/hash.js +94 -0
  110. data/node_modules/traceur/node_modules/rsvp/lib/rsvp/instrument.js +41 -0
  111. data/{vendor/node_modules → node_modules}/traceur/node_modules/rsvp/lib/rsvp/map.js +0 -0
  112. data/node_modules/traceur/node_modules/rsvp/lib/rsvp/node.js +281 -0
  113. data/node_modules/traceur/node_modules/rsvp/lib/rsvp/platform.js +14 -0
  114. data/node_modules/traceur/node_modules/rsvp/lib/rsvp/promise-hash.js +52 -0
  115. data/node_modules/traceur/node_modules/rsvp/lib/rsvp/promise.js +496 -0
  116. data/{vendor/node_modules → node_modules}/traceur/node_modules/rsvp/lib/rsvp/promise/all.js +0 -0
  117. data/node_modules/traceur/node_modules/rsvp/lib/rsvp/promise/race.js +105 -0
  118. data/node_modules/traceur/node_modules/rsvp/lib/rsvp/promise/reject.js +47 -0
  119. data/node_modules/traceur/node_modules/rsvp/lib/rsvp/promise/resolve.js +49 -0
  120. data/{vendor/node_modules → node_modules}/traceur/node_modules/rsvp/lib/rsvp/race.js +0 -0
  121. data/node_modules/traceur/node_modules/rsvp/lib/rsvp/reject.js +16 -0
  122. data/node_modules/traceur/node_modules/rsvp/lib/rsvp/resolve.js +17 -0
  123. data/{vendor/node_modules → node_modules}/traceur/node_modules/rsvp/lib/rsvp/rethrow.js +0 -0
  124. data/{vendor/node_modules → node_modules}/traceur/node_modules/rsvp/lib/rsvp/utils.js +0 -0
  125. data/node_modules/traceur/node_modules/rsvp/package.json +106 -0
  126. data/{vendor/node_modules → node_modules}/traceur/node_modules/semver/.npmignore +0 -0
  127. data/{vendor/node_modules → node_modules}/traceur/node_modules/semver/LICENSE +0 -0
  128. data/{vendor/node_modules → node_modules}/traceur/node_modules/semver/Makefile +0 -0
  129. data/{vendor/node_modules → node_modules}/traceur/node_modules/semver/README.md +0 -0
  130. data/{vendor/node_modules → node_modules}/traceur/node_modules/semver/bin/semver +0 -0
  131. data/{vendor/node_modules → node_modules}/traceur/node_modules/semver/foot.js +0 -0
  132. data/{vendor/node_modules → node_modules}/traceur/node_modules/semver/head.js +0 -0
  133. data/node_modules/traceur/node_modules/semver/package.json +50 -0
  134. data/{vendor/node_modules → node_modules}/traceur/node_modules/semver/semver.browser.js +0 -0
  135. data/{vendor/node_modules → node_modules}/traceur/node_modules/semver/semver.browser.js.gz +0 -0
  136. data/{vendor/node_modules → node_modules}/traceur/node_modules/semver/semver.js +0 -0
  137. data/{vendor/node_modules → node_modules}/traceur/node_modules/semver/semver.min.js +0 -0
  138. data/{vendor/node_modules → node_modules}/traceur/node_modules/semver/semver.min.js.gz +0 -0
  139. data/{vendor/node_modules → node_modules}/traceur/node_modules/semver/test/amd.js +0 -0
  140. data/{vendor/node_modules → node_modules}/traceur/node_modules/semver/test/gtr.js +0 -0
  141. data/{vendor/node_modules → node_modules}/traceur/node_modules/semver/test/index.js +0 -0
  142. data/{vendor/node_modules → node_modules}/traceur/node_modules/semver/test/ltr.js +0 -0
  143. data/{vendor/node_modules → node_modules}/traceur/node_modules/semver/test/no-module.js +0 -0
  144. data/{vendor/node_modules → node_modules}/traceur/node_modules/source-map-support/.npmignore +0 -0
  145. data/{vendor/node_modules → node_modules}/traceur/node_modules/source-map-support/LICENSE.md +0 -0
  146. data/{vendor/node_modules → node_modules}/traceur/node_modules/source-map-support/README.md +0 -0
  147. data/node_modules/traceur/node_modules/source-map-support/amd-test/browser-source-map-support.js +89 -0
  148. data/{vendor/node_modules → node_modules}/traceur/node_modules/source-map-support/amd-test/index.html +0 -0
  149. data/{vendor/node_modules → node_modules}/traceur/node_modules/source-map-support/amd-test/require.js +0 -0
  150. data/{vendor/node_modules → node_modules}/traceur/node_modules/source-map-support/amd-test/script.coffee +0 -0
  151. data/{vendor/node_modules → node_modules}/traceur/node_modules/source-map-support/amd-test/script.js +0 -0
  152. data/{vendor/node_modules → node_modules}/traceur/node_modules/source-map-support/amd-test/script.map +0 -0
  153. data/node_modules/traceur/node_modules/source-map-support/browser-source-map-support.js +89 -0
  154. data/{vendor/node_modules → node_modules}/traceur/node_modules/source-map-support/browser-test/index.html +0 -0
  155. data/{vendor/node_modules → node_modules}/traceur/node_modules/source-map-support/browser-test/script.coffee +0 -0
  156. data/{vendor/node_modules → node_modules}/traceur/node_modules/source-map-support/browser-test/script.js +0 -0
  157. data/{vendor/node_modules → node_modules}/traceur/node_modules/source-map-support/browser-test/script.map +0 -0
  158. data/{vendor/node_modules → node_modules}/traceur/node_modules/source-map-support/build.js +0 -0
  159. data/{vendor/node_modules → node_modules}/traceur/node_modules/source-map-support/header-test/index.html +0 -0
  160. data/{vendor/node_modules → node_modules}/traceur/node_modules/source-map-support/header-test/script.coffee +0 -0
  161. data/{vendor/node_modules → node_modules}/traceur/node_modules/source-map-support/header-test/script.js +0 -0
  162. data/{vendor/node_modules → node_modules}/traceur/node_modules/source-map-support/header-test/script.map +0 -0
  163. data/{vendor/node_modules → node_modules}/traceur/node_modules/source-map-support/header-test/server.js +0 -0
  164. data/{vendor/node_modules → node_modules}/traceur/node_modules/source-map-support/node_modules/source-map/.npmignore +0 -0
  165. data/{vendor/node_modules → node_modules}/traceur/node_modules/source-map-support/node_modules/source-map/.travis.yml +0 -0
  166. data/{vendor/node_modules → node_modules}/traceur/node_modules/source-map-support/node_modules/source-map/CHANGELOG.md +0 -0
  167. data/{vendor/node_modules → node_modules}/traceur/node_modules/source-map-support/node_modules/source-map/LICENSE +0 -0
  168. data/{vendor/node_modules → node_modules}/traceur/node_modules/source-map-support/node_modules/source-map/Makefile.dryice.js +0 -0
  169. data/{vendor/node_modules → node_modules}/traceur/node_modules/source-map-support/node_modules/source-map/README.md +0 -0
  170. data/{vendor/node_modules → node_modules}/traceur/node_modules/source-map-support/node_modules/source-map/build/assert-shim.js +0 -0
  171. data/{vendor/node_modules → node_modules}/traceur/node_modules/source-map-support/node_modules/source-map/build/mini-require.js +0 -0
  172. data/{vendor/node_modules → node_modules}/traceur/node_modules/source-map-support/node_modules/source-map/build/prefix-source-map.jsm +0 -0
  173. data/{vendor/node_modules → node_modules}/traceur/node_modules/source-map-support/node_modules/source-map/build/prefix-utils.jsm +0 -0
  174. data/{vendor/node_modules → node_modules}/traceur/node_modules/source-map-support/node_modules/source-map/build/suffix-browser.js +0 -0
  175. data/{vendor/node_modules → node_modules}/traceur/node_modules/source-map-support/node_modules/source-map/build/suffix-source-map.jsm +0 -0
  176. data/{vendor/node_modules → node_modules}/traceur/node_modules/source-map-support/node_modules/source-map/build/suffix-utils.jsm +0 -0
  177. data/{vendor/node_modules → node_modules}/traceur/node_modules/source-map-support/node_modules/source-map/build/test-prefix.js +0 -0
  178. data/{vendor/node_modules → node_modules}/traceur/node_modules/source-map-support/node_modules/source-map/build/test-suffix.js +0 -0
  179. data/{vendor/node_modules → node_modules}/traceur/node_modules/source-map-support/node_modules/source-map/lib/source-map.js +0 -0
  180. data/{vendor/node_modules → node_modules}/traceur/node_modules/source-map-support/node_modules/source-map/lib/source-map/array-set.js +0 -0
  181. data/{vendor/node_modules → node_modules}/traceur/node_modules/source-map-support/node_modules/source-map/lib/source-map/base64-vlq.js +0 -0
  182. data/{vendor/node_modules → node_modules}/traceur/node_modules/source-map-support/node_modules/source-map/lib/source-map/base64.js +0 -0
  183. data/{vendor/node_modules → node_modules}/traceur/node_modules/source-map-support/node_modules/source-map/lib/source-map/binary-search.js +0 -0
  184. data/{vendor/node_modules → node_modules}/traceur/node_modules/source-map-support/node_modules/source-map/lib/source-map/source-map-consumer.js +0 -0
  185. data/{vendor/node_modules → node_modules}/traceur/node_modules/source-map-support/node_modules/source-map/lib/source-map/source-map-generator.js +0 -0
  186. data/{vendor/node_modules → node_modules}/traceur/node_modules/source-map-support/node_modules/source-map/lib/source-map/source-node.js +0 -0
  187. data/{vendor/node_modules → node_modules}/traceur/node_modules/source-map-support/node_modules/source-map/lib/source-map/util.js +0 -0
  188. data/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/node_modules/amdefine/LICENSE +58 -0
  189. data/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/node_modules/amdefine/README.md +171 -0
  190. data/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/node_modules/amdefine/amdefine.js +301 -0
  191. data/{vendor/node_modules → node_modules}/traceur/node_modules/source-map-support/node_modules/source-map/node_modules/amdefine/intercept.js +0 -0
  192. data/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/node_modules/amdefine/package.json +47 -0
  193. data/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/package.json +142 -0
  194. data/{vendor/node_modules → node_modules}/traceur/node_modules/source-map-support/node_modules/source-map/test/run-tests.js +0 -0
  195. data/{vendor/node_modules → node_modules}/traceur/node_modules/source-map-support/node_modules/source-map/test/source-map/test-api.js +0 -0
  196. data/{vendor/node_modules → node_modules}/traceur/node_modules/source-map-support/node_modules/source-map/test/source-map/test-array-set.js +0 -0
  197. data/{vendor/node_modules → node_modules}/traceur/node_modules/source-map-support/node_modules/source-map/test/source-map/test-base64-vlq.js +0 -0
  198. data/{vendor/node_modules → node_modules}/traceur/node_modules/source-map-support/node_modules/source-map/test/source-map/test-base64.js +0 -0
  199. data/{vendor/node_modules → node_modules}/traceur/node_modules/source-map-support/node_modules/source-map/test/source-map/test-binary-search.js +0 -0
  200. data/{vendor/node_modules → node_modules}/traceur/node_modules/source-map-support/node_modules/source-map/test/source-map/test-dog-fooding.js +0 -0
  201. data/{vendor/node_modules → node_modules}/traceur/node_modules/source-map-support/node_modules/source-map/test/source-map/test-source-map-consumer.js +0 -0
  202. data/{vendor/node_modules → node_modules}/traceur/node_modules/source-map-support/node_modules/source-map/test/source-map/test-source-map-generator.js +0 -0
  203. data/{vendor/node_modules → node_modules}/traceur/node_modules/source-map-support/node_modules/source-map/test/source-map/test-source-node.js +0 -0
  204. data/{vendor/node_modules → node_modules}/traceur/node_modules/source-map-support/node_modules/source-map/test/source-map/util.js +0 -0
  205. data/node_modules/traceur/node_modules/source-map-support/package.json +52 -0
  206. data/node_modules/traceur/node_modules/source-map-support/source-map-support.js +386 -0
  207. data/node_modules/traceur/node_modules/source-map-support/test.js +384 -0
  208. data/node_modules/traceur/package.json +286 -0
  209. data/node_modules/traceur/src/node/NodeCompiler.js +81 -0
  210. data/{vendor/node_modules → node_modules}/traceur/src/node/System.js +0 -0
  211. data/{vendor/node_modules → node_modules}/traceur/src/node/api.js +0 -0
  212. data/node_modules/traceur/src/node/command.js +203 -0
  213. data/{vendor/node_modules → node_modules}/traceur/src/node/compileAllJsFilesInDir.js +0 -0
  214. data/{vendor/node_modules → node_modules}/traceur/src/node/deferred.js +0 -0
  215. data/{vendor/node_modules → node_modules}/traceur/src/node/file-util.js +0 -0
  216. data/{vendor/node_modules → node_modules}/traceur/src/node/getopt.js +0 -0
  217. data/node_modules/traceur/src/node/interpreter.js +37 -0
  218. data/{vendor/node_modules → node_modules}/traceur/src/node/nodeLoader.js +0 -0
  219. data/node_modules/traceur/src/node/recursiveModuleCompile.js +171 -0
  220. data/{vendor/node_modules → node_modules}/traceur/src/node/require.js +0 -0
  221. data/{vendor/node_modules → node_modules}/traceur/src/node/to-amd-compiler.js +0 -0
  222. data/{vendor/node_modules → node_modules}/traceur/src/node/to-closure-compiler.js +0 -0
  223. data/{vendor/node_modules → node_modules}/traceur/src/node/to-commonjs-compiler.js +0 -0
  224. data/{vendor/node_modules → node_modules}/traceur/src/node/traceur.js +0 -0
  225. data/{vendor/node_modules → node_modules}/traceur/traceur +0 -0
  226. data/package.json +15 -0
  227. data/spec/traceur/configuration_spec.rb +3 -3
  228. metadata +225 -161
@@ -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} [options] 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,14 @@
1
+ var platform;
2
+
3
+ /* global self */
4
+ if (typeof self === 'object') {
5
+ platform = self;
6
+
7
+ /* global global */
8
+ } else if (typeof global === 'object') {
9
+ platform = global;
10
+ } else {
11
+ throw new Error('no global: `self` or `global` found');
12
+ }
13
+
14
+ export default platform;
@@ -0,0 +1,52 @@
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 enumerator = this;
31
+ var promise = enumerator.promise;
32
+ var input = enumerator._input;
33
+ var results = [];
34
+
35
+ for (var key in input) {
36
+ if (promise._state === PENDING && Object.prototype.hasOwnProperty.call(input, key)) {
37
+ results.push({
38
+ position: key,
39
+ entry: input[key]
40
+ });
41
+ }
42
+ }
43
+
44
+ var length = results.length;
45
+ enumerator._remaining = length;
46
+ var result;
47
+
48
+ for (var i = 0; promise._state === PENDING && i < length; i++) {
49
+ result = results[i];
50
+ enumerator._eachEntry(result.entry, result.position);
51
+ }
52
+ };
@@ -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
+ export default function Promise(resolver, label) {
139
+ var promise = this;
140
+
141
+ promise._id = counter++;
142
+ promise._label = label;
143
+ promise._state = undefined;
144
+ promise._result = undefined;
145
+ promise._subscribers = [];
146
+
147
+ if (config.instrument) {
148
+ instrument('created', promise);
149
+ }
150
+
151
+ if (noop !== resolver) {
152
+ if (!isFunction(resolver)) {
153
+ needsResolver();
154
+ }
155
+
156
+ if (!(promise instanceof Promise)) {
157
+ needsNew();
158
+ }
159
+
160
+ initializePromise(promise, resolver);
161
+ }
162
+ }
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
+ var promise = this;
177
+ config.after(function() {
178
+ if (promise._onError) {
179
+ config['trigger']('error', reason);
180
+ }
181
+ });
182
+ },
183
+
184
+ /**
185
+ The primary way of interacting with a promise is through its `then` method,
186
+ which registers callbacks to receive either a promise's eventual value or the
187
+ reason why the promise cannot be fulfilled.
188
+
189
+ ```js
190
+ findUser().then(function(user){
191
+ // user is available
192
+ }, function(reason){
193
+ // user is unavailable, and you are given the reason why
194
+ });
195
+ ```
196
+
197
+ Chaining
198
+ --------
199
+
200
+ The return value of `then` is itself a promise. This second, 'downstream'
201
+ promise is resolved with the return value of the first promise's fulfillment
202
+ or rejection handler, or rejected if the handler throws an exception.
203
+
204
+ ```js
205
+ findUser().then(function (user) {
206
+ return user.name;
207
+ }, function (reason) {
208
+ return 'default name';
209
+ }).then(function (userName) {
210
+ // If `findUser` fulfilled, `userName` will be the user's name, otherwise it
211
+ // will be `'default name'`
212
+ });
213
+
214
+ findUser().then(function (user) {
215
+ throw new Error('Found user, but still unhappy');
216
+ }, function (reason) {
217
+ throw new Error('`findUser` rejected and we're unhappy');
218
+ }).then(function (value) {
219
+ // never reached
220
+ }, function (reason) {
221
+ // if `findUser` fulfilled, `reason` will be 'Found user, but still unhappy'.
222
+ // If `findUser` rejected, `reason` will be '`findUser` rejected and we're unhappy'.
223
+ });
224
+ ```
225
+ If the downstream promise does not specify a rejection handler, rejection reasons will be propagated further downstream.
226
+
227
+ ```js
228
+ findUser().then(function (user) {
229
+ throw new PedagogicalException('Upstream error');
230
+ }).then(function (value) {
231
+ // never reached
232
+ }).then(function (value) {
233
+ // never reached
234
+ }, function (reason) {
235
+ // The `PedgagocialException` is propagated all the way down to here
236
+ });
237
+ ```
238
+
239
+ Assimilation
240
+ ------------
241
+
242
+ Sometimes the value you want to propagate to a downstream promise can only be
243
+ retrieved asynchronously. This can be achieved by returning a promise in the
244
+ fulfillment or rejection handler. The downstream promise will then be pending
245
+ until the returned promise is settled. This is called *assimilation*.
246
+
247
+ ```js
248
+ findUser().then(function (user) {
249
+ return findCommentsByAuthor(user);
250
+ }).then(function (comments) {
251
+ // The user's comments are now available
252
+ });
253
+ ```
254
+
255
+ If the assimliated promise rejects, then the downstream promise will also reject.
256
+
257
+ ```js
258
+ findUser().then(function (user) {
259
+ return findCommentsByAuthor(user);
260
+ }).then(function (comments) {
261
+ // If `findCommentsByAuthor` fulfills, we'll have the value here
262
+ }, function (reason) {
263
+ // If `findCommentsByAuthor` rejects, we'll have the reason here
264
+ });
265
+ ```
266
+
267
+ Simple Example
268
+ --------------
269
+
270
+ Synchronous Example
271
+
272
+ ```javascript
273
+ var result;
274
+
275
+ try {
276
+ result = findResult();
277
+ // success
278
+ } catch(reason) {
279
+ // failure
280
+ }
281
+ ```
282
+
283
+ Errback Example
284
+
285
+ ```js
286
+ findResult(function(result, err){
287
+ if (err) {
288
+ // failure
289
+ } else {
290
+ // success
291
+ }
292
+ });
293
+ ```
294
+
295
+ Promise Example;
296
+
297
+ ```javascript
298
+ findResult().then(function(result){
299
+ // success
300
+ }, function(reason){
301
+ // failure
302
+ });
303
+ ```
304
+
305
+ Advanced Example
306
+ --------------
307
+
308
+ Synchronous Example
309
+
310
+ ```javascript
311
+ var author, books;
312
+
313
+ try {
314
+ author = findAuthor();
315
+ books = findBooksByAuthor(author);
316
+ // success
317
+ } catch(reason) {
318
+ // failure
319
+ }
320
+ ```
321
+
322
+ Errback Example
323
+
324
+ ```js
325
+
326
+ function foundBooks(books) {
327
+
328
+ }
329
+
330
+ function failure(reason) {
331
+
332
+ }
333
+
334
+ findAuthor(function(author, err){
335
+ if (err) {
336
+ failure(err);
337
+ // failure
338
+ } else {
339
+ try {
340
+ findBoooksByAuthor(author, function(books, err) {
341
+ if (err) {
342
+ failure(err);
343
+ } else {
344
+ try {
345
+ foundBooks(books);
346
+ } catch(reason) {
347
+ failure(reason);
348
+ }
349
+ }
350
+ });
351
+ } catch(error) {
352
+ failure(err);
353
+ }
354
+ // success
355
+ }
356
+ });
357
+ ```
358
+
359
+ Promise Example;
360
+
361
+ ```javascript
362
+ findAuthor().
363
+ then(findBooksByAuthor).
364
+ then(function(books){
365
+ // found books
366
+ }).catch(function(reason){
367
+ // something went wrong
368
+ });
369
+ ```
370
+
371
+ @method then
372
+ @param {Function} onFulfillment
373
+ @param {Function} onRejection
374
+ @param {String} label optional string for labeling the promise.
375
+ Useful for tooling.
376
+ @return {Promise}
377
+ */
378
+ then: function(onFulfillment, onRejection, label) {
379
+ var parent = this;
380
+ var state = parent._state;
381
+
382
+ if (state === FULFILLED && !onFulfillment || state === REJECTED && !onRejection) {
383
+ if (config.instrument) {
384
+ instrument('chained', parent, parent);
385
+ }
386
+ return parent;
387
+ }
388
+
389
+ parent._onError = null;
390
+
391
+ var child = new parent.constructor(noop, label);
392
+ var result = parent._result;
393
+
394
+ if (config.instrument) {
395
+ instrument('chained', parent, child);
396
+ }
397
+
398
+ if (state) {
399
+ var callback = arguments[state - 1];
400
+ config.async(function(){
401
+ invokeCallback(state, child, callback, result);
402
+ });
403
+ } else {
404
+ subscribe(parent, child, onFulfillment, onRejection);
405
+ }
406
+
407
+ return child;
408
+ },
409
+
410
+ /**
411
+ `catch` is simply sugar for `then(undefined, onRejection)` which makes it the same
412
+ as the catch block of a try/catch statement.
413
+
414
+ ```js
415
+ function findAuthor(){
416
+ throw new Error('couldn't find that author');
417
+ }
418
+
419
+ // synchronous
420
+ try {
421
+ findAuthor();
422
+ } catch(reason) {
423
+ // something went wrong
424
+ }
425
+
426
+ // async with promises
427
+ findAuthor().catch(function(reason){
428
+ // something went wrong
429
+ });
430
+ ```
431
+
432
+ @method catch
433
+ @param {Function} onRejection
434
+ @param {String} label optional string for labeling the promise.
435
+ Useful for tooling.
436
+ @return {Promise}
437
+ */
438
+ 'catch': function(onRejection, label) {
439
+ return this.then(undefined, onRejection, label);
440
+ },
441
+
442
+ /**
443
+ `finally` will be invoked regardless of the promise's fate just as native
444
+ try/catch/finally behaves
445
+
446
+ Synchronous example:
447
+
448
+ ```js
449
+ findAuthor() {
450
+ if (Math.random() > 0.5) {
451
+ throw new Error();
452
+ }
453
+ return new Author();
454
+ }
455
+
456
+ try {
457
+ return findAuthor(); // succeed or fail
458
+ } catch(error) {
459
+ return findOtherAuther();
460
+ } finally {
461
+ // always runs
462
+ // doesn't affect the return value
463
+ }
464
+ ```
465
+
466
+ Asynchronous example:
467
+
468
+ ```js
469
+ findAuthor().catch(function(reason){
470
+ return findOtherAuther();
471
+ }).finally(function(){
472
+ // author was either found, or not
473
+ });
474
+ ```
475
+
476
+ @method finally
477
+ @param {Function} callback
478
+ @param {String} label optional string for labeling the promise.
479
+ Useful for tooling.
480
+ @return {Promise}
481
+ */
482
+ 'finally': function(callback, label) {
483
+ var promise = this;
484
+ var constructor = promise.constructor;
485
+
486
+ return promise.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
+ };