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,1671 @@
1
+ /*!
2
+ * @overview RSVP - a tiny implementation of Promises/A+.
3
+ * @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors
4
+ * @license Licensed under MIT license
5
+ * See https://raw.githubusercontent.com/tildeio/rsvp.js/master/LICENSE
6
+ * @version 3.0.16
7
+ */
8
+
9
+ (function() {
10
+ "use strict";
11
+ function $$rsvp$events$$indexOf(callbacks, callback) {
12
+ for (var i=0, l=callbacks.length; i<l; i++) {
13
+ if (callbacks[i] === callback) { return i; }
14
+ }
15
+
16
+ return -1;
17
+ }
18
+
19
+ function $$rsvp$events$$callbacksFor(object) {
20
+ var callbacks = object._promiseCallbacks;
21
+
22
+ if (!callbacks) {
23
+ callbacks = object._promiseCallbacks = {};
24
+ }
25
+
26
+ return callbacks;
27
+ }
28
+
29
+ var $$rsvp$events$$default = {
30
+
31
+ /**
32
+ `RSVP.EventTarget.mixin` extends an object with EventTarget methods. For
33
+ Example:
34
+
35
+ ```javascript
36
+ var object = {};
37
+
38
+ RSVP.EventTarget.mixin(object);
39
+
40
+ object.on('finished', function(event) {
41
+ // handle event
42
+ });
43
+
44
+ object.trigger('finished', { detail: value });
45
+ ```
46
+
47
+ `EventTarget.mixin` also works with prototypes:
48
+
49
+ ```javascript
50
+ var Person = function() {};
51
+ RSVP.EventTarget.mixin(Person.prototype);
52
+
53
+ var yehuda = new Person();
54
+ var tom = new Person();
55
+
56
+ yehuda.on('poke', function(event) {
57
+ console.log('Yehuda says OW');
58
+ });
59
+
60
+ tom.on('poke', function(event) {
61
+ console.log('Tom says OW');
62
+ });
63
+
64
+ yehuda.trigger('poke');
65
+ tom.trigger('poke');
66
+ ```
67
+
68
+ @method mixin
69
+ @for RSVP.EventTarget
70
+ @private
71
+ @param {Object} object object to extend with EventTarget methods
72
+ */
73
+ 'mixin': function(object) {
74
+ object['on'] = this['on'];
75
+ object['off'] = this['off'];
76
+ object['trigger'] = this['trigger'];
77
+ object._promiseCallbacks = undefined;
78
+ return object;
79
+ },
80
+
81
+ /**
82
+ Registers a callback to be executed when `eventName` is triggered
83
+
84
+ ```javascript
85
+ object.on('event', function(eventInfo){
86
+ // handle the event
87
+ });
88
+
89
+ object.trigger('event');
90
+ ```
91
+
92
+ @method on
93
+ @for RSVP.EventTarget
94
+ @private
95
+ @param {String} eventName name of the event to listen for
96
+ @param {Function} callback function to be called when the event is triggered.
97
+ */
98
+ 'on': function(eventName, callback) {
99
+ var allCallbacks = $$rsvp$events$$callbacksFor(this), callbacks;
100
+
101
+ callbacks = allCallbacks[eventName];
102
+
103
+ if (!callbacks) {
104
+ callbacks = allCallbacks[eventName] = [];
105
+ }
106
+
107
+ if ($$rsvp$events$$indexOf(callbacks, callback) === -1) {
108
+ callbacks.push(callback);
109
+ }
110
+ },
111
+
112
+ /**
113
+ You can use `off` to stop firing a particular callback for an event:
114
+
115
+ ```javascript
116
+ function doStuff() { // do stuff! }
117
+ object.on('stuff', doStuff);
118
+
119
+ object.trigger('stuff'); // doStuff will be called
120
+
121
+ // Unregister ONLY the doStuff callback
122
+ object.off('stuff', doStuff);
123
+ object.trigger('stuff'); // doStuff will NOT be called
124
+ ```
125
+
126
+ If you don't pass a `callback` argument to `off`, ALL callbacks for the
127
+ event will not be executed when the event fires. For example:
128
+
129
+ ```javascript
130
+ var callback1 = function(){};
131
+ var callback2 = function(){};
132
+
133
+ object.on('stuff', callback1);
134
+ object.on('stuff', callback2);
135
+
136
+ object.trigger('stuff'); // callback1 and callback2 will be executed.
137
+
138
+ object.off('stuff');
139
+ object.trigger('stuff'); // callback1 and callback2 will not be executed!
140
+ ```
141
+
142
+ @method off
143
+ @for RSVP.EventTarget
144
+ @private
145
+ @param {String} eventName event to stop listening to
146
+ @param {Function} callback optional argument. If given, only the function
147
+ given will be removed from the event's callback queue. If no `callback`
148
+ argument is given, all callbacks will be removed from the event's callback
149
+ queue.
150
+ */
151
+ 'off': function(eventName, callback) {
152
+ var allCallbacks = $$rsvp$events$$callbacksFor(this), callbacks, index;
153
+
154
+ if (!callback) {
155
+ allCallbacks[eventName] = [];
156
+ return;
157
+ }
158
+
159
+ callbacks = allCallbacks[eventName];
160
+
161
+ index = $$rsvp$events$$indexOf(callbacks, callback);
162
+
163
+ if (index !== -1) { callbacks.splice(index, 1); }
164
+ },
165
+
166
+ /**
167
+ Use `trigger` to fire custom events. For example:
168
+
169
+ ```javascript
170
+ object.on('foo', function(){
171
+ console.log('foo event happened!');
172
+ });
173
+ object.trigger('foo');
174
+ // 'foo event happened!' logged to the console
175
+ ```
176
+
177
+ You can also pass a value as a second argument to `trigger` that will be
178
+ passed as an argument to all event listeners for the event:
179
+
180
+ ```javascript
181
+ object.on('foo', function(value){
182
+ console.log(value.name);
183
+ });
184
+
185
+ object.trigger('foo', { name: 'bar' });
186
+ // 'bar' logged to the console
187
+ ```
188
+
189
+ @method trigger
190
+ @for RSVP.EventTarget
191
+ @private
192
+ @param {String} eventName name of the event to be triggered
193
+ @param {Any} options optional value to be passed to any event handlers for
194
+ the given `eventName`
195
+ */
196
+ 'trigger': function(eventName, options) {
197
+ var allCallbacks = $$rsvp$events$$callbacksFor(this), callbacks, callback;
198
+
199
+ if (callbacks = allCallbacks[eventName]) {
200
+ // Don't cache the callbacks.length since it may grow
201
+ for (var i=0; i<callbacks.length; i++) {
202
+ callback = callbacks[i];
203
+
204
+ callback(options);
205
+ }
206
+ }
207
+ }
208
+ };
209
+
210
+ var $$rsvp$config$$config = {
211
+ instrument: false
212
+ };
213
+
214
+ $$rsvp$events$$default['mixin']($$rsvp$config$$config);
215
+
216
+ function $$rsvp$config$$configure(name, value) {
217
+ if (name === 'onerror') {
218
+ // handle for legacy users that expect the actual
219
+ // error to be passed to their function added via
220
+ // `RSVP.configure('onerror', someFunctionHere);`
221
+ $$rsvp$config$$config['on']('error', value);
222
+ return;
223
+ }
224
+
225
+ if (arguments.length === 2) {
226
+ $$rsvp$config$$config[name] = value;
227
+ } else {
228
+ return $$rsvp$config$$config[name];
229
+ }
230
+ }
231
+
232
+ function $$utils$$objectOrFunction(x) {
233
+ return typeof x === 'function' || (typeof x === 'object' && x !== null);
234
+ }
235
+
236
+ function $$utils$$isFunction(x) {
237
+ return typeof x === 'function';
238
+ }
239
+
240
+ function $$utils$$isMaybeThenable(x) {
241
+ return typeof x === 'object' && x !== null;
242
+ }
243
+
244
+ var $$utils$$_isArray;
245
+ if (!Array.isArray) {
246
+ $$utils$$_isArray = function (x) {
247
+ return Object.prototype.toString.call(x) === '[object Array]';
248
+ };
249
+ } else {
250
+ $$utils$$_isArray = Array.isArray;
251
+ }
252
+
253
+ var $$utils$$isArray = $$utils$$_isArray;
254
+
255
+ var $$utils$$now = Date.now || function() { return new Date().getTime(); };
256
+
257
+ function $$utils$$F() { }
258
+
259
+ var $$utils$$o_create = (Object.create || function (o) {
260
+ if (arguments.length > 1) {
261
+ throw new Error('Second argument not supported');
262
+ }
263
+ if (typeof o !== 'object') {
264
+ throw new TypeError('Argument must be an object');
265
+ }
266
+ $$utils$$F.prototype = o;
267
+ return new $$utils$$F();
268
+ });
269
+
270
+ var $$instrument$$queue = [];
271
+
272
+ function $$instrument$$scheduleFlush() {
273
+ setTimeout(function() {
274
+ var entry;
275
+ for (var i = 0; i < $$instrument$$queue.length; i++) {
276
+ entry = $$instrument$$queue[i];
277
+
278
+ var payload = entry.payload;
279
+
280
+ payload.guid = payload.key + payload.id;
281
+ payload.childGuid = payload.key + payload.childId;
282
+ if (payload.error) {
283
+ payload.stack = payload.error.stack;
284
+ }
285
+
286
+ $$rsvp$config$$config['trigger'](entry.name, entry.payload);
287
+ }
288
+ $$instrument$$queue.length = 0;
289
+ }, 50);
290
+ }
291
+
292
+ function $$instrument$$instrument(eventName, promise, child) {
293
+ if (1 === $$instrument$$queue.push({
294
+ name: eventName,
295
+ payload: {
296
+ key: promise._guidKey,
297
+ id: promise._id,
298
+ eventName: eventName,
299
+ detail: promise._result,
300
+ childId: child && child._id,
301
+ label: promise._label,
302
+ timeStamp: $$utils$$now(),
303
+ error: $$rsvp$config$$config["instrument-with-stack"] ? new Error(promise._label) : null
304
+ }})) {
305
+ $$instrument$$scheduleFlush();
306
+ }
307
+ }
308
+ var $$instrument$$default = $$instrument$$instrument;
309
+
310
+ function $$$internal$$withOwnPromise() {
311
+ return new TypeError('A promises callback cannot return that same promise.');
312
+ }
313
+
314
+ function $$$internal$$noop() {}
315
+
316
+ var $$$internal$$PENDING = void 0;
317
+ var $$$internal$$FULFILLED = 1;
318
+ var $$$internal$$REJECTED = 2;
319
+
320
+ var $$$internal$$GET_THEN_ERROR = new $$$internal$$ErrorObject();
321
+
322
+ function $$$internal$$getThen(promise) {
323
+ try {
324
+ return promise.then;
325
+ } catch(error) {
326
+ $$$internal$$GET_THEN_ERROR.error = error;
327
+ return $$$internal$$GET_THEN_ERROR;
328
+ }
329
+ }
330
+
331
+ function $$$internal$$tryThen(then, value, fulfillmentHandler, rejectionHandler) {
332
+ try {
333
+ then.call(value, fulfillmentHandler, rejectionHandler);
334
+ } catch(e) {
335
+ return e;
336
+ }
337
+ }
338
+
339
+ function $$$internal$$handleForeignThenable(promise, thenable, then) {
340
+ $$rsvp$config$$config.async(function(promise) {
341
+ var sealed = false;
342
+ var error = $$$internal$$tryThen(then, thenable, function(value) {
343
+ if (sealed) { return; }
344
+ sealed = true;
345
+ if (thenable !== value) {
346
+ $$$internal$$resolve(promise, value);
347
+ } else {
348
+ $$$internal$$fulfill(promise, value);
349
+ }
350
+ }, function(reason) {
351
+ if (sealed) { return; }
352
+ sealed = true;
353
+
354
+ $$$internal$$reject(promise, reason);
355
+ }, 'Settle: ' + (promise._label || ' unknown promise'));
356
+
357
+ if (!sealed && error) {
358
+ sealed = true;
359
+ $$$internal$$reject(promise, error);
360
+ }
361
+ }, promise);
362
+ }
363
+
364
+ function $$$internal$$handleOwnThenable(promise, thenable) {
365
+ if (thenable._state === $$$internal$$FULFILLED) {
366
+ $$$internal$$fulfill(promise, thenable._result);
367
+ } else if (thenable._state === $$$internal$$REJECTED) {
368
+ thenable._onError = null;
369
+ $$$internal$$reject(promise, thenable._result);
370
+ } else {
371
+ $$$internal$$subscribe(thenable, undefined, function(value) {
372
+ if (thenable !== value) {
373
+ $$$internal$$resolve(promise, value);
374
+ } else {
375
+ $$$internal$$fulfill(promise, value);
376
+ }
377
+ }, function(reason) {
378
+ $$$internal$$reject(promise, reason);
379
+ });
380
+ }
381
+ }
382
+
383
+ function $$$internal$$handleMaybeThenable(promise, maybeThenable) {
384
+ if (maybeThenable.constructor === promise.constructor) {
385
+ $$$internal$$handleOwnThenable(promise, maybeThenable);
386
+ } else {
387
+ var then = $$$internal$$getThen(maybeThenable);
388
+
389
+ if (then === $$$internal$$GET_THEN_ERROR) {
390
+ $$$internal$$reject(promise, $$$internal$$GET_THEN_ERROR.error);
391
+ } else if (then === undefined) {
392
+ $$$internal$$fulfill(promise, maybeThenable);
393
+ } else if ($$utils$$isFunction(then)) {
394
+ $$$internal$$handleForeignThenable(promise, maybeThenable, then);
395
+ } else {
396
+ $$$internal$$fulfill(promise, maybeThenable);
397
+ }
398
+ }
399
+ }
400
+
401
+ function $$$internal$$resolve(promise, value) {
402
+ if (promise === value) {
403
+ $$$internal$$fulfill(promise, value);
404
+ } else if ($$utils$$objectOrFunction(value)) {
405
+ $$$internal$$handleMaybeThenable(promise, value);
406
+ } else {
407
+ $$$internal$$fulfill(promise, value);
408
+ }
409
+ }
410
+
411
+ function $$$internal$$publishRejection(promise) {
412
+ if (promise._onError) {
413
+ promise._onError(promise._result);
414
+ }
415
+
416
+ $$$internal$$publish(promise);
417
+ }
418
+
419
+ function $$$internal$$fulfill(promise, value) {
420
+ if (promise._state !== $$$internal$$PENDING) { return; }
421
+
422
+ promise._result = value;
423
+ promise._state = $$$internal$$FULFILLED;
424
+
425
+ if (promise._subscribers.length === 0) {
426
+ if ($$rsvp$config$$config.instrument) {
427
+ $$instrument$$default('fulfilled', promise);
428
+ }
429
+ } else {
430
+ $$rsvp$config$$config.async($$$internal$$publish, promise);
431
+ }
432
+ }
433
+
434
+ function $$$internal$$reject(promise, reason) {
435
+ if (promise._state !== $$$internal$$PENDING) { return; }
436
+ promise._state = $$$internal$$REJECTED;
437
+ promise._result = reason;
438
+ $$rsvp$config$$config.async($$$internal$$publishRejection, promise);
439
+ }
440
+
441
+ function $$$internal$$subscribe(parent, child, onFulfillment, onRejection) {
442
+ var subscribers = parent._subscribers;
443
+ var length = subscribers.length;
444
+
445
+ parent._onError = null;
446
+
447
+ subscribers[length] = child;
448
+ subscribers[length + $$$internal$$FULFILLED] = onFulfillment;
449
+ subscribers[length + $$$internal$$REJECTED] = onRejection;
450
+
451
+ if (length === 0 && parent._state) {
452
+ $$rsvp$config$$config.async($$$internal$$publish, parent);
453
+ }
454
+ }
455
+
456
+ function $$$internal$$publish(promise) {
457
+ var subscribers = promise._subscribers;
458
+ var settled = promise._state;
459
+
460
+ if ($$rsvp$config$$config.instrument) {
461
+ $$instrument$$default(settled === $$$internal$$FULFILLED ? 'fulfilled' : 'rejected', promise);
462
+ }
463
+
464
+ if (subscribers.length === 0) { return; }
465
+
466
+ var child, callback, detail = promise._result;
467
+
468
+ for (var i = 0; i < subscribers.length; i += 3) {
469
+ child = subscribers[i];
470
+ callback = subscribers[i + settled];
471
+
472
+ if (child) {
473
+ $$$internal$$invokeCallback(settled, child, callback, detail);
474
+ } else {
475
+ callback(detail);
476
+ }
477
+ }
478
+
479
+ promise._subscribers.length = 0;
480
+ }
481
+
482
+ function $$$internal$$ErrorObject() {
483
+ this.error = null;
484
+ }
485
+
486
+ var $$$internal$$TRY_CATCH_ERROR = new $$$internal$$ErrorObject();
487
+
488
+ function $$$internal$$tryCatch(callback, detail) {
489
+ try {
490
+ return callback(detail);
491
+ } catch(e) {
492
+ $$$internal$$TRY_CATCH_ERROR.error = e;
493
+ return $$$internal$$TRY_CATCH_ERROR;
494
+ }
495
+ }
496
+
497
+ function $$$internal$$invokeCallback(settled, promise, callback, detail) {
498
+ var hasCallback = $$utils$$isFunction(callback),
499
+ value, error, succeeded, failed;
500
+
501
+ if (hasCallback) {
502
+ value = $$$internal$$tryCatch(callback, detail);
503
+
504
+ if (value === $$$internal$$TRY_CATCH_ERROR) {
505
+ failed = true;
506
+ error = value.error;
507
+ value = null;
508
+ } else {
509
+ succeeded = true;
510
+ }
511
+
512
+ if (promise === value) {
513
+ $$$internal$$reject(promise, $$$internal$$withOwnPromise());
514
+ return;
515
+ }
516
+
517
+ } else {
518
+ value = detail;
519
+ succeeded = true;
520
+ }
521
+
522
+ if (promise._state !== $$$internal$$PENDING) {
523
+ // noop
524
+ } else if (hasCallback && succeeded) {
525
+ $$$internal$$resolve(promise, value);
526
+ } else if (failed) {
527
+ $$$internal$$reject(promise, error);
528
+ } else if (settled === $$$internal$$FULFILLED) {
529
+ $$$internal$$fulfill(promise, value);
530
+ } else if (settled === $$$internal$$REJECTED) {
531
+ $$$internal$$reject(promise, value);
532
+ }
533
+ }
534
+
535
+ function $$$internal$$initializePromise(promise, resolver) {
536
+ var resolved = false;
537
+ try {
538
+ resolver(function resolvePromise(value){
539
+ if (resolved) { return; }
540
+ resolved = true;
541
+ $$$internal$$resolve(promise, value);
542
+ }, function rejectPromise(reason) {
543
+ if (resolved) { return; }
544
+ resolved = true;
545
+ $$$internal$$reject(promise, reason);
546
+ });
547
+ } catch(e) {
548
+ $$$internal$$reject(promise, e);
549
+ }
550
+ }
551
+
552
+ function $$enumerator$$makeSettledResult(state, position, value) {
553
+ if (state === $$$internal$$FULFILLED) {
554
+ return {
555
+ state: 'fulfilled',
556
+ value: value
557
+ };
558
+ } else {
559
+ return {
560
+ state: 'rejected',
561
+ reason: value
562
+ };
563
+ }
564
+ }
565
+
566
+ function $$enumerator$$Enumerator(Constructor, input, abortOnReject, label) {
567
+ this._instanceConstructor = Constructor;
568
+ this.promise = new Constructor($$$internal$$noop, label);
569
+ this._abortOnReject = abortOnReject;
570
+
571
+ if (this._validateInput(input)) {
572
+ this._input = input;
573
+ this.length = input.length;
574
+ this._remaining = input.length;
575
+
576
+ this._init();
577
+
578
+ if (this.length === 0) {
579
+ $$$internal$$fulfill(this.promise, this._result);
580
+ } else {
581
+ this.length = this.length || 0;
582
+ this._enumerate();
583
+ if (this._remaining === 0) {
584
+ $$$internal$$fulfill(this.promise, this._result);
585
+ }
586
+ }
587
+ } else {
588
+ $$$internal$$reject(this.promise, this._validationError());
589
+ }
590
+ }
591
+
592
+ var $$enumerator$$default = $$enumerator$$Enumerator;
593
+
594
+ $$enumerator$$Enumerator.prototype._validateInput = function(input) {
595
+ return $$utils$$isArray(input);
596
+ };
597
+
598
+ $$enumerator$$Enumerator.prototype._validationError = function() {
599
+ return new Error('Array Methods must be provided an Array');
600
+ };
601
+
602
+ $$enumerator$$Enumerator.prototype._init = function() {
603
+ this._result = new Array(this.length);
604
+ };
605
+
606
+ $$enumerator$$Enumerator.prototype._enumerate = function() {
607
+ var length = this.length;
608
+ var promise = this.promise;
609
+ var input = this._input;
610
+
611
+ for (var i = 0; promise._state === $$$internal$$PENDING && i < length; i++) {
612
+ this._eachEntry(input[i], i);
613
+ }
614
+ };
615
+
616
+ $$enumerator$$Enumerator.prototype._eachEntry = function(entry, i) {
617
+ var c = this._instanceConstructor;
618
+ if ($$utils$$isMaybeThenable(entry)) {
619
+ if (entry.constructor === c && entry._state !== $$$internal$$PENDING) {
620
+ entry._onError = null;
621
+ this._settledAt(entry._state, i, entry._result);
622
+ } else {
623
+ this._willSettleAt(c.resolve(entry), i);
624
+ }
625
+ } else {
626
+ this._remaining--;
627
+ this._result[i] = this._makeResult($$$internal$$FULFILLED, i, entry);
628
+ }
629
+ };
630
+
631
+ $$enumerator$$Enumerator.prototype._settledAt = function(state, i, value) {
632
+ var promise = this.promise;
633
+
634
+ if (promise._state === $$$internal$$PENDING) {
635
+ this._remaining--;
636
+
637
+ if (this._abortOnReject && state === $$$internal$$REJECTED) {
638
+ $$$internal$$reject(promise, value);
639
+ } else {
640
+ this._result[i] = this._makeResult(state, i, value);
641
+ }
642
+ }
643
+
644
+ if (this._remaining === 0) {
645
+ $$$internal$$fulfill(promise, this._result);
646
+ }
647
+ };
648
+
649
+ $$enumerator$$Enumerator.prototype._makeResult = function(state, i, value) {
650
+ return value;
651
+ };
652
+
653
+ $$enumerator$$Enumerator.prototype._willSettleAt = function(promise, i) {
654
+ var enumerator = this;
655
+
656
+ $$$internal$$subscribe(promise, undefined, function(value) {
657
+ enumerator._settledAt($$$internal$$FULFILLED, i, value);
658
+ }, function(reason) {
659
+ enumerator._settledAt($$$internal$$REJECTED, i, reason);
660
+ });
661
+ };
662
+ function $$promise$all$$all(entries, label) {
663
+ return new $$enumerator$$default(this, entries, true /* abort on reject */, label).promise;
664
+ }
665
+ var $$promise$all$$default = $$promise$all$$all;
666
+ function $$promise$race$$race(entries, label) {
667
+ /*jshint validthis:true */
668
+ var Constructor = this;
669
+
670
+ var promise = new Constructor($$$internal$$noop, label);
671
+
672
+ if (!$$utils$$isArray(entries)) {
673
+ $$$internal$$reject(promise, new TypeError('You must pass an array to race.'));
674
+ return promise;
675
+ }
676
+
677
+ var length = entries.length;
678
+
679
+ function onFulfillment(value) {
680
+ $$$internal$$resolve(promise, value);
681
+ }
682
+
683
+ function onRejection(reason) {
684
+ $$$internal$$reject(promise, reason);
685
+ }
686
+
687
+ for (var i = 0; promise._state === $$$internal$$PENDING && i < length; i++) {
688
+ $$$internal$$subscribe(Constructor.resolve(entries[i]), undefined, onFulfillment, onRejection);
689
+ }
690
+
691
+ return promise;
692
+ }
693
+ var $$promise$race$$default = $$promise$race$$race;
694
+ function $$promise$resolve$$resolve(object, label) {
695
+ /*jshint validthis:true */
696
+ var Constructor = this;
697
+
698
+ if (object && typeof object === 'object' && object.constructor === Constructor) {
699
+ return object;
700
+ }
701
+
702
+ var promise = new Constructor($$$internal$$noop, label);
703
+ $$$internal$$resolve(promise, object);
704
+ return promise;
705
+ }
706
+ var $$promise$resolve$$default = $$promise$resolve$$resolve;
707
+ function $$promise$reject$$reject(reason, label) {
708
+ /*jshint validthis:true */
709
+ var Constructor = this;
710
+ var promise = new Constructor($$$internal$$noop, label);
711
+ $$$internal$$reject(promise, reason);
712
+ return promise;
713
+ }
714
+ var $$promise$reject$$default = $$promise$reject$$reject;
715
+
716
+ var $$rsvp$promise$$guidKey = 'rsvp_' + $$utils$$now() + '-';
717
+ var $$rsvp$promise$$counter = 0;
718
+
719
+ function $$rsvp$promise$$needsResolver() {
720
+ throw new TypeError('You must pass a resolver function as the first argument to the promise constructor');
721
+ }
722
+
723
+ function $$rsvp$promise$$needsNew() {
724
+ throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.");
725
+ }
726
+
727
+ /**
728
+ Promise objects represent the eventual result of an asynchronous operation. The
729
+ primary way of interacting with a promise is through its `then` method, which
730
+ registers callbacks to receive either a promise’s eventual value or the reason
731
+ why the promise cannot be fulfilled.
732
+
733
+ Terminology
734
+ -----------
735
+
736
+ - `promise` is an object or function with a `then` method whose behavior conforms to this specification.
737
+ - `thenable` is an object or function that defines a `then` method.
738
+ - `value` is any legal JavaScript value (including undefined, a thenable, or a promise).
739
+ - `exception` is a value that is thrown using the throw statement.
740
+ - `reason` is a value that indicates why a promise was rejected.
741
+ - `settled` the final resting state of a promise, fulfilled or rejected.
742
+
743
+ A promise can be in one of three states: pending, fulfilled, or rejected.
744
+
745
+ Promises that are fulfilled have a fulfillment value and are in the fulfilled
746
+ state. Promises that are rejected have a rejection reason and are in the
747
+ rejected state. A fulfillment value is never a thenable.
748
+
749
+ Promises can also be said to *resolve* a value. If this value is also a
750
+ promise, then the original promise's settled state will match the value's
751
+ settled state. So a promise that *resolves* a promise that rejects will
752
+ itself reject, and a promise that *resolves* a promise that fulfills will
753
+ itself fulfill.
754
+
755
+
756
+ Basic Usage:
757
+ ------------
758
+
759
+ ```js
760
+ var promise = new Promise(function(resolve, reject) {
761
+ // on success
762
+ resolve(value);
763
+
764
+ // on failure
765
+ reject(reason);
766
+ });
767
+
768
+ promise.then(function(value) {
769
+ // on fulfillment
770
+ }, function(reason) {
771
+ // on rejection
772
+ });
773
+ ```
774
+
775
+ Advanced Usage:
776
+ ---------------
777
+
778
+ Promises shine when abstracting away asynchronous interactions such as
779
+ `XMLHttpRequest`s.
780
+
781
+ ```js
782
+ function getJSON(url) {
783
+ return new Promise(function(resolve, reject){
784
+ var xhr = new XMLHttpRequest();
785
+
786
+ xhr.open('GET', url);
787
+ xhr.onreadystatechange = handler;
788
+ xhr.responseType = 'json';
789
+ xhr.setRequestHeader('Accept', 'application/json');
790
+ xhr.send();
791
+
792
+ function handler() {
793
+ if (this.readyState === this.DONE) {
794
+ if (this.status === 200) {
795
+ resolve(this.response);
796
+ } else {
797
+ reject(new Error('getJSON: `' + url + '` failed with status: [' + this.status + ']'));
798
+ }
799
+ }
800
+ };
801
+ });
802
+ }
803
+
804
+ getJSON('/posts.json').then(function(json) {
805
+ // on fulfillment
806
+ }, function(reason) {
807
+ // on rejection
808
+ });
809
+ ```
810
+
811
+ Unlike callbacks, promises are great composable primitives.
812
+
813
+ ```js
814
+ Promise.all([
815
+ getJSON('/posts'),
816
+ getJSON('/comments')
817
+ ]).then(function(values){
818
+ values[0] // => postsJSON
819
+ values[1] // => commentsJSON
820
+
821
+ return values;
822
+ });
823
+ ```
824
+
825
+ @class RSVP.Promise
826
+ @param {function} resolver
827
+ @param {String} label optional string for labeling the promise.
828
+ Useful for tooling.
829
+ @constructor
830
+ */
831
+ function $$rsvp$promise$$Promise(resolver, label) {
832
+ this._id = $$rsvp$promise$$counter++;
833
+ this._label = label;
834
+ this._state = undefined;
835
+ this._result = undefined;
836
+ this._subscribers = [];
837
+
838
+ if ($$rsvp$config$$config.instrument) {
839
+ $$instrument$$default('created', this);
840
+ }
841
+
842
+ if ($$$internal$$noop !== resolver) {
843
+ if (!$$utils$$isFunction(resolver)) {
844
+ $$rsvp$promise$$needsResolver();
845
+ }
846
+
847
+ if (!(this instanceof $$rsvp$promise$$Promise)) {
848
+ $$rsvp$promise$$needsNew();
849
+ }
850
+
851
+ $$$internal$$initializePromise(this, resolver);
852
+ }
853
+ }
854
+
855
+ var $$rsvp$promise$$default = $$rsvp$promise$$Promise;
856
+
857
+ // deprecated
858
+ $$rsvp$promise$$Promise.cast = $$promise$resolve$$default;
859
+ $$rsvp$promise$$Promise.all = $$promise$all$$default;
860
+ $$rsvp$promise$$Promise.race = $$promise$race$$default;
861
+ $$rsvp$promise$$Promise.resolve = $$promise$resolve$$default;
862
+ $$rsvp$promise$$Promise.reject = $$promise$reject$$default;
863
+
864
+ $$rsvp$promise$$Promise.prototype = {
865
+ constructor: $$rsvp$promise$$Promise,
866
+
867
+ _guidKey: $$rsvp$promise$$guidKey,
868
+
869
+ _onError: function (reason) {
870
+ $$rsvp$config$$config.async(function(promise) {
871
+ setTimeout(function() {
872
+ if (promise._onError) {
873
+ $$rsvp$config$$config['trigger']('error', reason);
874
+ }
875
+ }, 0);
876
+ }, this);
877
+ },
878
+
879
+ /**
880
+ The primary way of interacting with a promise is through its `then` method,
881
+ which registers callbacks to receive either a promise's eventual value or the
882
+ reason why the promise cannot be fulfilled.
883
+
884
+ ```js
885
+ findUser().then(function(user){
886
+ // user is available
887
+ }, function(reason){
888
+ // user is unavailable, and you are given the reason why
889
+ });
890
+ ```
891
+
892
+ Chaining
893
+ --------
894
+
895
+ The return value of `then` is itself a promise. This second, 'downstream'
896
+ promise is resolved with the return value of the first promise's fulfillment
897
+ or rejection handler, or rejected if the handler throws an exception.
898
+
899
+ ```js
900
+ findUser().then(function (user) {
901
+ return user.name;
902
+ }, function (reason) {
903
+ return 'default name';
904
+ }).then(function (userName) {
905
+ // If `findUser` fulfilled, `userName` will be the user's name, otherwise it
906
+ // will be `'default name'`
907
+ });
908
+
909
+ findUser().then(function (user) {
910
+ throw new Error('Found user, but still unhappy');
911
+ }, function (reason) {
912
+ throw new Error('`findUser` rejected and we're unhappy');
913
+ }).then(function (value) {
914
+ // never reached
915
+ }, function (reason) {
916
+ // if `findUser` fulfilled, `reason` will be 'Found user, but still unhappy'.
917
+ // If `findUser` rejected, `reason` will be '`findUser` rejected and we're unhappy'.
918
+ });
919
+ ```
920
+ If the downstream promise does not specify a rejection handler, rejection reasons will be propagated further downstream.
921
+
922
+ ```js
923
+ findUser().then(function (user) {
924
+ throw new PedagogicalException('Upstream error');
925
+ }).then(function (value) {
926
+ // never reached
927
+ }).then(function (value) {
928
+ // never reached
929
+ }, function (reason) {
930
+ // The `PedgagocialException` is propagated all the way down to here
931
+ });
932
+ ```
933
+
934
+ Assimilation
935
+ ------------
936
+
937
+ Sometimes the value you want to propagate to a downstream promise can only be
938
+ retrieved asynchronously. This can be achieved by returning a promise in the
939
+ fulfillment or rejection handler. The downstream promise will then be pending
940
+ until the returned promise is settled. This is called *assimilation*.
941
+
942
+ ```js
943
+ findUser().then(function (user) {
944
+ return findCommentsByAuthor(user);
945
+ }).then(function (comments) {
946
+ // The user's comments are now available
947
+ });
948
+ ```
949
+
950
+ If the assimliated promise rejects, then the downstream promise will also reject.
951
+
952
+ ```js
953
+ findUser().then(function (user) {
954
+ return findCommentsByAuthor(user);
955
+ }).then(function (comments) {
956
+ // If `findCommentsByAuthor` fulfills, we'll have the value here
957
+ }, function (reason) {
958
+ // If `findCommentsByAuthor` rejects, we'll have the reason here
959
+ });
960
+ ```
961
+
962
+ Simple Example
963
+ --------------
964
+
965
+ Synchronous Example
966
+
967
+ ```javascript
968
+ var result;
969
+
970
+ try {
971
+ result = findResult();
972
+ // success
973
+ } catch(reason) {
974
+ // failure
975
+ }
976
+ ```
977
+
978
+ Errback Example
979
+
980
+ ```js
981
+ findResult(function(result, err){
982
+ if (err) {
983
+ // failure
984
+ } else {
985
+ // success
986
+ }
987
+ });
988
+ ```
989
+
990
+ Promise Example;
991
+
992
+ ```javascript
993
+ findResult().then(function(result){
994
+ // success
995
+ }, function(reason){
996
+ // failure
997
+ });
998
+ ```
999
+
1000
+ Advanced Example
1001
+ --------------
1002
+
1003
+ Synchronous Example
1004
+
1005
+ ```javascript
1006
+ var author, books;
1007
+
1008
+ try {
1009
+ author = findAuthor();
1010
+ books = findBooksByAuthor(author);
1011
+ // success
1012
+ } catch(reason) {
1013
+ // failure
1014
+ }
1015
+ ```
1016
+
1017
+ Errback Example
1018
+
1019
+ ```js
1020
+
1021
+ function foundBooks(books) {
1022
+
1023
+ }
1024
+
1025
+ function failure(reason) {
1026
+
1027
+ }
1028
+
1029
+ findAuthor(function(author, err){
1030
+ if (err) {
1031
+ failure(err);
1032
+ // failure
1033
+ } else {
1034
+ try {
1035
+ findBoooksByAuthor(author, function(books, err) {
1036
+ if (err) {
1037
+ failure(err);
1038
+ } else {
1039
+ try {
1040
+ foundBooks(books);
1041
+ } catch(reason) {
1042
+ failure(reason);
1043
+ }
1044
+ }
1045
+ });
1046
+ } catch(error) {
1047
+ failure(err);
1048
+ }
1049
+ // success
1050
+ }
1051
+ });
1052
+ ```
1053
+
1054
+ Promise Example;
1055
+
1056
+ ```javascript
1057
+ findAuthor().
1058
+ then(findBooksByAuthor).
1059
+ then(function(books){
1060
+ // found books
1061
+ }).catch(function(reason){
1062
+ // something went wrong
1063
+ });
1064
+ ```
1065
+
1066
+ @method then
1067
+ @param {Function} onFulfilled
1068
+ @param {Function} onRejected
1069
+ @param {String} label optional string for labeling the promise.
1070
+ Useful for tooling.
1071
+ @return {Promise}
1072
+ */
1073
+ then: function(onFulfillment, onRejection, label) {
1074
+ var parent = this;
1075
+ var state = parent._state;
1076
+
1077
+ if (state === $$$internal$$FULFILLED && !onFulfillment || state === $$$internal$$REJECTED && !onRejection) {
1078
+ if ($$rsvp$config$$config.instrument) {
1079
+ $$instrument$$default('chained', this, this);
1080
+ }
1081
+ return this;
1082
+ }
1083
+
1084
+ parent._onError = null;
1085
+
1086
+ var child = new this.constructor($$$internal$$noop, label);
1087
+ var result = parent._result;
1088
+
1089
+ if ($$rsvp$config$$config.instrument) {
1090
+ $$instrument$$default('chained', parent, child);
1091
+ }
1092
+
1093
+ if (state) {
1094
+ var callback = arguments[state - 1];
1095
+ $$rsvp$config$$config.async(function(){
1096
+ $$$internal$$invokeCallback(state, child, callback, result);
1097
+ });
1098
+ } else {
1099
+ $$$internal$$subscribe(parent, child, onFulfillment, onRejection);
1100
+ }
1101
+
1102
+ return child;
1103
+ },
1104
+
1105
+ /**
1106
+ `catch` is simply sugar for `then(undefined, onRejection)` which makes it the same
1107
+ as the catch block of a try/catch statement.
1108
+
1109
+ ```js
1110
+ function findAuthor(){
1111
+ throw new Error('couldn't find that author');
1112
+ }
1113
+
1114
+ // synchronous
1115
+ try {
1116
+ findAuthor();
1117
+ } catch(reason) {
1118
+ // something went wrong
1119
+ }
1120
+
1121
+ // async with promises
1122
+ findAuthor().catch(function(reason){
1123
+ // something went wrong
1124
+ });
1125
+ ```
1126
+
1127
+ @method catch
1128
+ @param {Function} onRejection
1129
+ @param {String} label optional string for labeling the promise.
1130
+ Useful for tooling.
1131
+ @return {Promise}
1132
+ */
1133
+ 'catch': function(onRejection, label) {
1134
+ return this.then(null, onRejection, label);
1135
+ },
1136
+
1137
+ /**
1138
+ `finally` will be invoked regardless of the promise's fate just as native
1139
+ try/catch/finally behaves
1140
+
1141
+ Synchronous example:
1142
+
1143
+ ```js
1144
+ findAuthor() {
1145
+ if (Math.random() > 0.5) {
1146
+ throw new Error();
1147
+ }
1148
+ return new Author();
1149
+ }
1150
+
1151
+ try {
1152
+ return findAuthor(); // succeed or fail
1153
+ } catch(error) {
1154
+ return findOtherAuther();
1155
+ } finally {
1156
+ // always runs
1157
+ // doesn't affect the return value
1158
+ }
1159
+ ```
1160
+
1161
+ Asynchronous example:
1162
+
1163
+ ```js
1164
+ findAuthor().catch(function(reason){
1165
+ return findOtherAuther();
1166
+ }).finally(function(){
1167
+ // author was either found, or not
1168
+ });
1169
+ ```
1170
+
1171
+ @method finally
1172
+ @param {Function} callback
1173
+ @param {String} label optional string for labeling the promise.
1174
+ Useful for tooling.
1175
+ @return {Promise}
1176
+ */
1177
+ 'finally': function(callback, label) {
1178
+ var constructor = this.constructor;
1179
+
1180
+ return this.then(function(value) {
1181
+ return constructor.resolve(callback()).then(function(){
1182
+ return value;
1183
+ });
1184
+ }, function(reason) {
1185
+ return constructor.resolve(callback()).then(function(){
1186
+ throw reason;
1187
+ });
1188
+ }, label);
1189
+ }
1190
+ };
1191
+
1192
+ function $$rsvp$node$$Result() {
1193
+ this.value = undefined;
1194
+ }
1195
+
1196
+ var $$rsvp$node$$ERROR = new $$rsvp$node$$Result();
1197
+ var $$rsvp$node$$GET_THEN_ERROR = new $$rsvp$node$$Result();
1198
+
1199
+ function $$rsvp$node$$getThen(obj) {
1200
+ try {
1201
+ return obj.then;
1202
+ } catch(error) {
1203
+ $$rsvp$node$$ERROR.value= error;
1204
+ return $$rsvp$node$$ERROR;
1205
+ }
1206
+ }
1207
+
1208
+
1209
+ function $$rsvp$node$$tryApply(f, s, a) {
1210
+ try {
1211
+ f.apply(s, a);
1212
+ } catch(error) {
1213
+ $$rsvp$node$$ERROR.value = error;
1214
+ return $$rsvp$node$$ERROR;
1215
+ }
1216
+ }
1217
+
1218
+ function $$rsvp$node$$makeObject(_, argumentNames) {
1219
+ var obj = {};
1220
+ var name;
1221
+ var i;
1222
+ var length = _.length;
1223
+ var args = new Array(length);
1224
+
1225
+ for (var x = 0; x < length; x++) {
1226
+ args[x] = _[x];
1227
+ }
1228
+
1229
+ for (i = 0; i < argumentNames.length; i++) {
1230
+ name = argumentNames[i];
1231
+ obj[name] = args[i + 1];
1232
+ }
1233
+
1234
+ return obj;
1235
+ }
1236
+
1237
+ function $$rsvp$node$$arrayResult(_) {
1238
+ var length = _.length;
1239
+ var args = new Array(length - 1);
1240
+
1241
+ for (var i = 1; i < length; i++) {
1242
+ args[i - 1] = _[i];
1243
+ }
1244
+
1245
+ return args;
1246
+ }
1247
+
1248
+ function $$rsvp$node$$wrapThenable(then, promise) {
1249
+ return {
1250
+ then: function(onFulFillment, onRejection) {
1251
+ return then.call(promise, onFulFillment, onRejection);
1252
+ }
1253
+ };
1254
+ }
1255
+
1256
+ function $$rsvp$node$$denodeify(nodeFunc, options) {
1257
+ var fn = function() {
1258
+ var self = this;
1259
+ var l = arguments.length;
1260
+ var args = new Array(l + 1);
1261
+ var arg;
1262
+ var promiseInput = false;
1263
+
1264
+ for (var i = 0; i < l; ++i) {
1265
+ arg = arguments[i];
1266
+
1267
+ if (!promiseInput) {
1268
+ // TODO: clean this up
1269
+ promiseInput = $$rsvp$node$$needsPromiseInput(arg);
1270
+ if (promiseInput === $$rsvp$node$$GET_THEN_ERROR) {
1271
+ var p = new $$rsvp$promise$$default($$$internal$$noop);
1272
+ $$$internal$$reject(p, $$rsvp$node$$GET_THEN_ERROR.value);
1273
+ return p;
1274
+ } else if (promiseInput && promiseInput !== true) {
1275
+ arg = $$rsvp$node$$wrapThenable(promiseInput, arg);
1276
+ }
1277
+ }
1278
+ args[i] = arg;
1279
+ }
1280
+
1281
+ var promise = new $$rsvp$promise$$default($$$internal$$noop);
1282
+
1283
+ args[l] = function(err, val) {
1284
+ if (err)
1285
+ $$$internal$$reject(promise, err);
1286
+ else if (options === undefined)
1287
+ $$$internal$$resolve(promise, val);
1288
+ else if (options === true)
1289
+ $$$internal$$resolve(promise, $$rsvp$node$$arrayResult(arguments));
1290
+ else if ($$utils$$isArray(options))
1291
+ $$$internal$$resolve(promise, $$rsvp$node$$makeObject(arguments, options));
1292
+ else
1293
+ $$$internal$$resolve(promise, val);
1294
+ };
1295
+
1296
+ if (promiseInput) {
1297
+ return $$rsvp$node$$handlePromiseInput(promise, args, nodeFunc, self);
1298
+ } else {
1299
+ return $$rsvp$node$$handleValueInput(promise, args, nodeFunc, self);
1300
+ }
1301
+ };
1302
+
1303
+ fn.__proto__ = nodeFunc;
1304
+
1305
+ return fn;
1306
+ }
1307
+
1308
+ var $$rsvp$node$$default = $$rsvp$node$$denodeify;
1309
+
1310
+ function $$rsvp$node$$handleValueInput(promise, args, nodeFunc, self) {
1311
+ var result = $$rsvp$node$$tryApply(nodeFunc, self, args);
1312
+ if (result === $$rsvp$node$$ERROR) {
1313
+ $$$internal$$reject(promise, result.value);
1314
+ }
1315
+ return promise;
1316
+ }
1317
+
1318
+ function $$rsvp$node$$handlePromiseInput(promise, args, nodeFunc, self){
1319
+ return $$rsvp$promise$$default.all(args).then(function(args){
1320
+ var result = $$rsvp$node$$tryApply(nodeFunc, self, args);
1321
+ if (result === $$rsvp$node$$ERROR) {
1322
+ $$$internal$$reject(promise, result.value);
1323
+ }
1324
+ return promise;
1325
+ });
1326
+ }
1327
+
1328
+ function $$rsvp$node$$needsPromiseInput(arg) {
1329
+ if (arg && typeof arg === 'object') {
1330
+ if (arg.constructor === $$rsvp$promise$$default) {
1331
+ return true;
1332
+ } else {
1333
+ return $$rsvp$node$$getThen(arg);
1334
+ }
1335
+ } else {
1336
+ return false;
1337
+ }
1338
+ }
1339
+ function $$rsvp$all$$all(array, label) {
1340
+ return $$rsvp$promise$$default.all(array, label);
1341
+ }
1342
+ var $$rsvp$all$$default = $$rsvp$all$$all;
1343
+
1344
+ function $$rsvp$all$settled$$AllSettled(Constructor, entries, label) {
1345
+ this._superConstructor(Constructor, entries, false /* don't abort on reject */, label);
1346
+ }
1347
+
1348
+ $$rsvp$all$settled$$AllSettled.prototype = $$utils$$o_create($$enumerator$$default.prototype);
1349
+ $$rsvp$all$settled$$AllSettled.prototype._superConstructor = $$enumerator$$default;
1350
+ $$rsvp$all$settled$$AllSettled.prototype._makeResult = $$enumerator$$makeSettledResult;
1351
+ $$rsvp$all$settled$$AllSettled.prototype._validationError = function() {
1352
+ return new Error('allSettled must be called with an array');
1353
+ };
1354
+
1355
+ function $$rsvp$all$settled$$allSettled(entries, label) {
1356
+ return new $$rsvp$all$settled$$AllSettled($$rsvp$promise$$default, entries, label).promise;
1357
+ }
1358
+ var $$rsvp$all$settled$$default = $$rsvp$all$settled$$allSettled;
1359
+ function $$rsvp$race$$race(array, label) {
1360
+ return $$rsvp$promise$$default.race(array, label);
1361
+ }
1362
+ var $$rsvp$race$$default = $$rsvp$race$$race;
1363
+
1364
+ function $$promise$hash$$PromiseHash(Constructor, object, label) {
1365
+ this._superConstructor(Constructor, object, true, label);
1366
+ }
1367
+
1368
+ var $$promise$hash$$default = $$promise$hash$$PromiseHash;
1369
+
1370
+ $$promise$hash$$PromiseHash.prototype = $$utils$$o_create($$enumerator$$default.prototype);
1371
+ $$promise$hash$$PromiseHash.prototype._superConstructor = $$enumerator$$default;
1372
+ $$promise$hash$$PromiseHash.prototype._init = function() {
1373
+ this._result = {};
1374
+ };
1375
+
1376
+ $$promise$hash$$PromiseHash.prototype._validateInput = function(input) {
1377
+ return input && typeof input === 'object';
1378
+ };
1379
+
1380
+ $$promise$hash$$PromiseHash.prototype._validationError = function() {
1381
+ return new Error('Promise.hash must be called with an object');
1382
+ };
1383
+
1384
+ $$promise$hash$$PromiseHash.prototype._enumerate = function() {
1385
+ var promise = this.promise;
1386
+ var input = this._input;
1387
+ var results = [];
1388
+
1389
+ for (var key in input) {
1390
+ if (promise._state === $$$internal$$PENDING && input.hasOwnProperty(key)) {
1391
+ results.push({
1392
+ position: key,
1393
+ entry: input[key]
1394
+ });
1395
+ }
1396
+ }
1397
+
1398
+ var length = results.length;
1399
+ this._remaining = length;
1400
+ var result;
1401
+
1402
+ for (var i = 0; promise._state === $$$internal$$PENDING && i < length; i++) {
1403
+ result = results[i];
1404
+ this._eachEntry(result.entry, result.position);
1405
+ }
1406
+ };
1407
+ function $$rsvp$hash$$hash(object, label) {
1408
+ return new $$promise$hash$$default($$rsvp$promise$$default, object, label).promise;
1409
+ }
1410
+ var $$rsvp$hash$$default = $$rsvp$hash$$hash;
1411
+
1412
+ function $$rsvp$hash$settled$$HashSettled(Constructor, object, label) {
1413
+ this._superConstructor(Constructor, object, false, label);
1414
+ }
1415
+
1416
+ $$rsvp$hash$settled$$HashSettled.prototype = $$utils$$o_create($$promise$hash$$default.prototype);
1417
+ $$rsvp$hash$settled$$HashSettled.prototype._superConstructor = $$enumerator$$default;
1418
+ $$rsvp$hash$settled$$HashSettled.prototype._makeResult = $$enumerator$$makeSettledResult;
1419
+
1420
+ $$rsvp$hash$settled$$HashSettled.prototype._validationError = function() {
1421
+ return new Error('hashSettled must be called with an object');
1422
+ };
1423
+
1424
+ function $$rsvp$hash$settled$$hashSettled(object, label) {
1425
+ return new $$rsvp$hash$settled$$HashSettled($$rsvp$promise$$default, object, label).promise;
1426
+ }
1427
+ var $$rsvp$hash$settled$$default = $$rsvp$hash$settled$$hashSettled;
1428
+ function $$rsvp$rethrow$$rethrow(reason) {
1429
+ setTimeout(function() {
1430
+ throw reason;
1431
+ });
1432
+ throw reason;
1433
+ }
1434
+ var $$rsvp$rethrow$$default = $$rsvp$rethrow$$rethrow;
1435
+ function $$rsvp$defer$$defer(label) {
1436
+ var deferred = { };
1437
+
1438
+ deferred['promise'] = new $$rsvp$promise$$default(function(resolve, reject) {
1439
+ deferred['resolve'] = resolve;
1440
+ deferred['reject'] = reject;
1441
+ }, label);
1442
+
1443
+ return deferred;
1444
+ }
1445
+ var $$rsvp$defer$$default = $$rsvp$defer$$defer;
1446
+ function $$rsvp$map$$map(promises, mapFn, label) {
1447
+ return $$rsvp$promise$$default.all(promises, label).then(function(values) {
1448
+ if (!$$utils$$isFunction(mapFn)) {
1449
+ throw new TypeError("You must pass a function as map's second argument.");
1450
+ }
1451
+
1452
+ var length = values.length;
1453
+ var results = new Array(length);
1454
+
1455
+ for (var i = 0; i < length; i++) {
1456
+ results[i] = mapFn(values[i]);
1457
+ }
1458
+
1459
+ return $$rsvp$promise$$default.all(results, label);
1460
+ });
1461
+ }
1462
+ var $$rsvp$map$$default = $$rsvp$map$$map;
1463
+ function $$rsvp$resolve$$resolve(value, label) {
1464
+ return $$rsvp$promise$$default.resolve(value, label);
1465
+ }
1466
+ var $$rsvp$resolve$$default = $$rsvp$resolve$$resolve;
1467
+ function $$rsvp$reject$$reject(reason, label) {
1468
+ return $$rsvp$promise$$default.reject(reason, label);
1469
+ }
1470
+ var $$rsvp$reject$$default = $$rsvp$reject$$reject;
1471
+ function $$rsvp$filter$$filter(promises, filterFn, label) {
1472
+ return $$rsvp$promise$$default.all(promises, label).then(function(values) {
1473
+ if (!$$utils$$isFunction(filterFn)) {
1474
+ throw new TypeError("You must pass a function as filter's second argument.");
1475
+ }
1476
+
1477
+ var length = values.length;
1478
+ var filtered = new Array(length);
1479
+
1480
+ for (var i = 0; i < length; i++) {
1481
+ filtered[i] = filterFn(values[i]);
1482
+ }
1483
+
1484
+ return $$rsvp$promise$$default.all(filtered, label).then(function(filtered) {
1485
+ var results = new Array(length);
1486
+ var newLength = 0;
1487
+
1488
+ for (var i = 0; i < length; i++) {
1489
+ if (filtered[i]) {
1490
+ results[newLength] = values[i];
1491
+ newLength++;
1492
+ }
1493
+ }
1494
+
1495
+ results.length = newLength;
1496
+
1497
+ return results;
1498
+ });
1499
+ });
1500
+ }
1501
+ var $$rsvp$filter$$default = $$rsvp$filter$$filter;
1502
+ var $$rsvp$asap$$len = 0;
1503
+
1504
+ function $$rsvp$asap$$asap(callback, arg) {
1505
+ $$rsvp$asap$$queue[$$rsvp$asap$$len] = callback;
1506
+ $$rsvp$asap$$queue[$$rsvp$asap$$len + 1] = arg;
1507
+ $$rsvp$asap$$len += 2;
1508
+ if ($$rsvp$asap$$len === 2) {
1509
+ // If len is 1, that means that we need to schedule an async flush.
1510
+ // If additional callbacks are queued before the queue is flushed, they
1511
+ // will be processed by this flush that we are scheduling.
1512
+ $$rsvp$asap$$scheduleFlush();
1513
+ }
1514
+ }
1515
+
1516
+ var $$rsvp$asap$$default = $$rsvp$asap$$asap;
1517
+
1518
+ var $$rsvp$asap$$browserWindow = (typeof window !== 'undefined') ? window : undefined;
1519
+ var $$rsvp$asap$$browserGlobal = $$rsvp$asap$$browserWindow || {};
1520
+ var $$rsvp$asap$$BrowserMutationObserver = $$rsvp$asap$$browserGlobal.MutationObserver || $$rsvp$asap$$browserGlobal.WebKitMutationObserver;
1521
+ var $$rsvp$asap$$isNode = typeof process !== 'undefined' && {}.toString.call(process) === '[object process]';
1522
+
1523
+ // test for web worker but not in IE10
1524
+ var $$rsvp$asap$$isWorker = typeof Uint8ClampedArray !== 'undefined' &&
1525
+ typeof importScripts !== 'undefined' &&
1526
+ typeof MessageChannel !== 'undefined';
1527
+
1528
+ // node
1529
+ function $$rsvp$asap$$useNextTick() {
1530
+ var nextTick = process.nextTick;
1531
+ // node version 0.10.x displays a deprecation warning when nextTick is used recursively
1532
+ // setImmediate should be used instead instead
1533
+ var version = process.versions.node.match(/^(?:(\d+)\.)?(?:(\d+)\.)?(\*|\d+)$/);
1534
+ if (Array.isArray(version) && version[1] === '0' && version[2] === '10') {
1535
+ nextTick = setImmediate;
1536
+ }
1537
+ return function() {
1538
+ nextTick($$rsvp$asap$$flush);
1539
+ };
1540
+ }
1541
+
1542
+ // vertx
1543
+ function $$rsvp$asap$$useVertxTimer() {
1544
+ return function() {
1545
+ vertxNext($$rsvp$asap$$flush);
1546
+ };
1547
+ }
1548
+
1549
+ function $$rsvp$asap$$useMutationObserver() {
1550
+ var iterations = 0;
1551
+ var observer = new $$rsvp$asap$$BrowserMutationObserver($$rsvp$asap$$flush);
1552
+ var node = document.createTextNode('');
1553
+ observer.observe(node, { characterData: true });
1554
+
1555
+ return function() {
1556
+ node.data = (iterations = ++iterations % 2);
1557
+ };
1558
+ }
1559
+
1560
+ // web worker
1561
+ function $$rsvp$asap$$useMessageChannel() {
1562
+ var channel = new MessageChannel();
1563
+ channel.port1.onmessage = $$rsvp$asap$$flush;
1564
+ return function () {
1565
+ channel.port2.postMessage(0);
1566
+ };
1567
+ }
1568
+
1569
+ function $$rsvp$asap$$useSetTimeout() {
1570
+ return function() {
1571
+ setTimeout($$rsvp$asap$$flush, 1);
1572
+ };
1573
+ }
1574
+
1575
+ var $$rsvp$asap$$queue = new Array(1000);
1576
+ function $$rsvp$asap$$flush() {
1577
+ for (var i = 0; i < $$rsvp$asap$$len; i+=2) {
1578
+ var callback = $$rsvp$asap$$queue[i];
1579
+ var arg = $$rsvp$asap$$queue[i+1];
1580
+
1581
+ callback(arg);
1582
+
1583
+ $$rsvp$asap$$queue[i] = undefined;
1584
+ $$rsvp$asap$$queue[i+1] = undefined;
1585
+ }
1586
+
1587
+ $$rsvp$asap$$len = 0;
1588
+ }
1589
+
1590
+ function $$rsvp$asap$$attemptVertex() {
1591
+ try {
1592
+ var vertx = require('vertx');
1593
+ var vertxNext = vertx.runOnLoop || vertx.runOnContext;
1594
+ return $$rsvp$asap$$useVertxTimer();
1595
+ } catch(e) {
1596
+ return $$rsvp$asap$$useSetTimeout();
1597
+ }
1598
+ }
1599
+
1600
+ var $$rsvp$asap$$scheduleFlush;
1601
+ // Decide what async method to use to triggering processing of queued callbacks:
1602
+ if ($$rsvp$asap$$isNode) {
1603
+ $$rsvp$asap$$scheduleFlush = $$rsvp$asap$$useNextTick();
1604
+ } else if ($$rsvp$asap$$BrowserMutationObserver) {
1605
+ $$rsvp$asap$$scheduleFlush = $$rsvp$asap$$useMutationObserver();
1606
+ } else if ($$rsvp$asap$$isWorker) {
1607
+ $$rsvp$asap$$scheduleFlush = $$rsvp$asap$$useMessageChannel();
1608
+ } else if ($$rsvp$asap$$browserWindow === undefined && typeof require === 'function') {
1609
+ $$rsvp$asap$$scheduleFlush = $$rsvp$asap$$attemptVertex();
1610
+ } else {
1611
+ $$rsvp$asap$$scheduleFlush = $$rsvp$asap$$useSetTimeout();
1612
+ }
1613
+
1614
+ // default async is asap;
1615
+ $$rsvp$config$$config.async = $$rsvp$asap$$default;
1616
+ var $$rsvp$$cast = $$rsvp$resolve$$default;
1617
+ function $$rsvp$$async(callback, arg) {
1618
+ $$rsvp$config$$config.async(callback, arg);
1619
+ }
1620
+
1621
+ function $$rsvp$$on() {
1622
+ $$rsvp$config$$config['on'].apply($$rsvp$config$$config, arguments);
1623
+ }
1624
+
1625
+ function $$rsvp$$off() {
1626
+ $$rsvp$config$$config['off'].apply($$rsvp$config$$config, arguments);
1627
+ }
1628
+
1629
+ // Set up instrumentation through `window.__PROMISE_INTRUMENTATION__`
1630
+ if (typeof window !== 'undefined' && typeof window['__PROMISE_INSTRUMENTATION__'] === 'object') {
1631
+ var $$rsvp$$callbacks = window['__PROMISE_INSTRUMENTATION__'];
1632
+ $$rsvp$config$$configure('instrument', true);
1633
+ for (var $$rsvp$$eventName in $$rsvp$$callbacks) {
1634
+ if ($$rsvp$$callbacks.hasOwnProperty($$rsvp$$eventName)) {
1635
+ $$rsvp$$on($$rsvp$$eventName, $$rsvp$$callbacks[$$rsvp$$eventName]);
1636
+ }
1637
+ }
1638
+ }
1639
+
1640
+ var rsvp$umd$$RSVP = {
1641
+ 'race': $$rsvp$race$$default,
1642
+ 'Promise': $$rsvp$promise$$default,
1643
+ 'allSettled': $$rsvp$all$settled$$default,
1644
+ 'hash': $$rsvp$hash$$default,
1645
+ 'hashSettled': $$rsvp$hash$settled$$default,
1646
+ 'denodeify': $$rsvp$node$$default,
1647
+ 'on': $$rsvp$$on,
1648
+ 'off': $$rsvp$$off,
1649
+ 'map': $$rsvp$map$$default,
1650
+ 'filter': $$rsvp$filter$$default,
1651
+ 'resolve': $$rsvp$resolve$$default,
1652
+ 'reject': $$rsvp$reject$$default,
1653
+ 'all': $$rsvp$all$$default,
1654
+ 'rethrow': $$rsvp$rethrow$$default,
1655
+ 'defer': $$rsvp$defer$$default,
1656
+ 'EventTarget': $$rsvp$events$$default,
1657
+ 'configure': $$rsvp$config$$configure,
1658
+ 'async': $$rsvp$$async
1659
+ };
1660
+
1661
+ /* global define:true module:true window: true */
1662
+ if (typeof define === 'function' && define['amd']) {
1663
+ define(function() { return rsvp$umd$$RSVP; });
1664
+ } else if (typeof module !== 'undefined' && module['exports']) {
1665
+ module['exports'] = rsvp$umd$$RSVP;
1666
+ } else if (typeof this !== 'undefined') {
1667
+ this['RSVP'] = rsvp$umd$$RSVP;
1668
+ }
1669
+ }).call(this);
1670
+
1671
+ //# sourceMappingURL=rsvp.js.map