freezerwatch 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (314) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +10 -0
  3. data/CODE_OF_CONDUCT.md +13 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE.txt +21 -0
  6. data/README.md +40 -0
  7. data/Rakefile +1 -0
  8. data/bin/console +14 -0
  9. data/bin/freezerwatch +9 -0
  10. data/bin/setup +7 -0
  11. data/freezerwatch.gemspec +23 -0
  12. data/lib/freezerwatch.rb +5 -0
  13. data/lib/freezerwatch/version.rb +3 -0
  14. data/node_modules/.bin/freezerwatch +139 -0
  15. data/node_modules/freezerwatch/.npmignore +3 -0
  16. data/node_modules/freezerwatch/.ruby-version +1 -0
  17. data/node_modules/freezerwatch/Gemfile +4 -0
  18. data/node_modules/freezerwatch/Gemfile.lock +79 -0
  19. data/node_modules/freezerwatch/LICENSE +23 -0
  20. data/node_modules/freezerwatch/README.md +41 -0
  21. data/node_modules/freezerwatch/Rakefile +13 -0
  22. data/node_modules/freezerwatch/freezerwatch.js +139 -0
  23. data/node_modules/freezerwatch/metrics/bigfiles_high_water_mark +1 -0
  24. data/node_modules/freezerwatch/metrics/cane_high_water_mark +1 -0
  25. data/node_modules/freezerwatch/metrics/flay_high_water_mark +1 -0
  26. data/node_modules/freezerwatch/metrics/flog_high_water_mark +1 -0
  27. data/node_modules/freezerwatch/metrics/punchlist_high_water_mark +2 -0
  28. data/node_modules/freezerwatch/metrics/reek_high_water_mark +1 -0
  29. data/node_modules/freezerwatch/metrics/rubocop_high_water_mark +1 -0
  30. data/node_modules/freezerwatch/node_modules/async/.jshintrc +25 -0
  31. data/node_modules/freezerwatch/node_modules/async/.travis.yml +6 -0
  32. data/node_modules/freezerwatch/node_modules/async/CHANGELOG.md +65 -0
  33. data/node_modules/freezerwatch/node_modules/async/LICENSE +19 -0
  34. data/node_modules/freezerwatch/node_modules/async/README.md +1803 -0
  35. data/node_modules/freezerwatch/node_modules/async/bower.json +43 -0
  36. data/node_modules/freezerwatch/node_modules/async/component.json +17 -0
  37. data/node_modules/freezerwatch/node_modules/async/coverage/base.css +182 -0
  38. data/node_modules/freezerwatch/node_modules/async/coverage/index.html +73 -0
  39. data/node_modules/freezerwatch/node_modules/async/coverage/lcov-report/base.css +182 -0
  40. data/node_modules/freezerwatch/node_modules/async/coverage/lcov-report/index.html +73 -0
  41. data/node_modules/freezerwatch/node_modules/async/coverage/lcov-report/lib/async.js.html +3900 -0
  42. data/node_modules/freezerwatch/node_modules/async/coverage/lcov-report/lib/index.html +73 -0
  43. data/node_modules/freezerwatch/node_modules/async/coverage/lcov-report/prettify.css +1 -0
  44. data/node_modules/freezerwatch/node_modules/async/coverage/lcov-report/prettify.js +1 -0
  45. data/node_modules/freezerwatch/node_modules/async/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  46. data/node_modules/freezerwatch/node_modules/async/coverage/lcov-report/sorter.js +156 -0
  47. data/node_modules/freezerwatch/node_modules/async/coverage/lcov.info +1452 -0
  48. data/node_modules/freezerwatch/node_modules/async/coverage/lib/async.js.html +3597 -0
  49. data/node_modules/freezerwatch/node_modules/async/coverage/lib/index.html +73 -0
  50. data/node_modules/freezerwatch/node_modules/async/coverage/prettify.css +1 -0
  51. data/node_modules/freezerwatch/node_modules/async/coverage/prettify.js +1 -0
  52. data/node_modules/freezerwatch/node_modules/async/coverage/sort-arrow-sprite.png +0 -0
  53. data/node_modules/freezerwatch/node_modules/async/coverage/sorter.js +156 -0
  54. data/node_modules/freezerwatch/node_modules/async/lib/async.js +1191 -0
  55. data/node_modules/freezerwatch/node_modules/async/nyc_output/5074.json +1 -0
  56. data/node_modules/freezerwatch/node_modules/async/package.json +96 -0
  57. data/node_modules/freezerwatch/node_modules/async/support/sync-package-managers.js +53 -0
  58. data/node_modules/freezerwatch/node_modules/lacrosse/.npmignore +15 -0
  59. data/node_modules/freezerwatch/node_modules/lacrosse/Client.js +60 -0
  60. data/node_modules/freezerwatch/node_modules/lacrosse/Device.js +38 -0
  61. data/node_modules/freezerwatch/node_modules/lacrosse/DeviceRawReadStream.js +36 -0
  62. data/node_modules/freezerwatch/node_modules/lacrosse/DeviceSingleRawReadStream.js +29 -0
  63. data/node_modules/freezerwatch/node_modules/lacrosse/DeviceStream.js +35 -0
  64. data/node_modules/freezerwatch/node_modules/lacrosse/LICENSE +23 -0
  65. data/node_modules/freezerwatch/node_modules/lacrosse/README.md +25 -0
  66. data/node_modules/freezerwatch/node_modules/lacrosse/index.js +1 -0
  67. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/.npmignore +2 -0
  68. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/.travis.yml +12 -0
  69. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/LICENSE +55 -0
  70. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/README.md +364 -0
  71. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/index.js +156 -0
  72. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/lib/copy.js +8 -0
  73. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/lib/debug.js +7 -0
  74. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/lib/getSafe.js +34 -0
  75. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/lib/optional.js +5 -0
  76. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/.bin/uuid +26 -0
  77. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/aws-sign2/LICENSE +55 -0
  78. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/aws-sign2/README.md +4 -0
  79. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/aws-sign2/index.js +202 -0
  80. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/aws-sign2/package.json +46 -0
  81. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/forever-agent/LICENSE +55 -0
  82. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/forever-agent/README.md +4 -0
  83. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/forever-agent/index.js +119 -0
  84. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/forever-agent/package.json +45 -0
  85. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/License +19 -0
  86. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/Readme.md +175 -0
  87. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/lib/form_data.js +351 -0
  88. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/async/.travis.yml +5 -0
  89. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/async/LICENSE +19 -0
  90. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/async/README.md +1647 -0
  91. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/async/bower.json +38 -0
  92. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/async/component.json +16 -0
  93. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/async/lib/async.js +1123 -0
  94. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/async/package.json +84 -0
  95. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/async/support/sync-package-managers.js +53 -0
  96. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/combined-stream/License +19 -0
  97. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/combined-stream/Readme.md +132 -0
  98. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/combined-stream/lib/combined_stream.js +188 -0
  99. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/.npmignore +2 -0
  100. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/License +19 -0
  101. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/Makefile +7 -0
  102. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/Readme.md +154 -0
  103. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/lib/delayed_stream.js +99 -0
  104. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/package.json +42 -0
  105. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/common.js +6 -0
  106. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-http-upload.js +38 -0
  107. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-stream-auto-pause.js +21 -0
  108. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-stream-pause.js +14 -0
  109. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-stream.js +48 -0
  110. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-handle-source-errors.js +15 -0
  111. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-max-data-size.js +18 -0
  112. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-pipe-resumes.js +13 -0
  113. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-proxy-readable.js +13 -0
  114. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/run.js +7 -0
  115. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/combined-stream/package.json +60 -0
  116. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/package.json +80 -0
  117. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/.npmignore +18 -0
  118. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/.travis.yml +5 -0
  119. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/LICENSE +24 -0
  120. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/Makefile +10 -0
  121. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/README.md +627 -0
  122. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/example/usage.js +78 -0
  123. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/images/hawk.png +0 -0
  124. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/images/logo.png +0 -0
  125. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/index.js +1 -0
  126. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/lib/browser.js +485 -0
  127. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/lib/client.js +367 -0
  128. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/lib/crypto.js +111 -0
  129. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/lib/index.js +15 -0
  130. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/lib/server.js +524 -0
  131. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/lib/utils.js +183 -0
  132. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/boom/.npmignore +18 -0
  133. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/boom/.travis.yml +5 -0
  134. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/boom/LICENSE +24 -0
  135. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/boom/Makefile +11 -0
  136. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/boom/README.md +6 -0
  137. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/boom/images/boom.png +0 -0
  138. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/boom/index.js +1 -0
  139. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/boom/lib/index.js +207 -0
  140. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/boom/package.json +64 -0
  141. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/boom/test/index.js +245 -0
  142. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/cryptiles/.npmignore +18 -0
  143. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/cryptiles/.travis.yml +5 -0
  144. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/cryptiles/LICENSE +24 -0
  145. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/cryptiles/Makefile +11 -0
  146. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/cryptiles/README.md +6 -0
  147. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/cryptiles/index.js +1 -0
  148. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/cryptiles/lib/index.js +68 -0
  149. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/cryptiles/package.json +65 -0
  150. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/cryptiles/test/index.js +101 -0
  151. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/hoek/.npmignore +18 -0
  152. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/hoek/.travis.yml +5 -0
  153. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/hoek/LICENSE +33 -0
  154. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/hoek/Makefile +10 -0
  155. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/hoek/README.md +436 -0
  156. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/hoek/images/hoek.png +0 -0
  157. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/hoek/index.js +1 -0
  158. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/hoek/lib/escape.js +132 -0
  159. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/hoek/lib/index.js +585 -0
  160. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/hoek/package.json +70 -0
  161. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/hoek/test/escaper.js +86 -0
  162. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/hoek/test/index.js +1078 -0
  163. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/hoek/test/modules/test1.js +1 -0
  164. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/hoek/test/modules/test2.js +1 -0
  165. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/hoek/test/modules/test3.js +1 -0
  166. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/sntp/.npmignore +18 -0
  167. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/sntp/.travis.yml +5 -0
  168. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/sntp/LICENSE +24 -0
  169. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/sntp/Makefile +11 -0
  170. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/sntp/README.md +68 -0
  171. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/sntp/examples/offset.js +16 -0
  172. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/sntp/examples/time.js +25 -0
  173. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/sntp/index.js +1 -0
  174. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/sntp/lib/index.js +409 -0
  175. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/sntp/package.json +65 -0
  176. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/sntp/test/index.js +359 -0
  177. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/package.json +70 -0
  178. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/test/browser.js +771 -0
  179. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/test/client.js +206 -0
  180. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/test/crypto.js +86 -0
  181. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/test/index.js +316 -0
  182. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/test/message.js +246 -0
  183. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/test/readme.js +98 -0
  184. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/test/server.js +686 -0
  185. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/test/uri.js +456 -0
  186. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/test/utils.js +120 -0
  187. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/.dir-locals.el +6 -0
  188. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/.npmignore +7 -0
  189. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/LICENSE +18 -0
  190. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/README.md +79 -0
  191. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/http_signing.md +296 -0
  192. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/lib/index.js +26 -0
  193. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/lib/parser.js +304 -0
  194. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/lib/signer.js +178 -0
  195. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/lib/util.js +304 -0
  196. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/lib/verify.js +42 -0
  197. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/asn1/.npmignore +2 -0
  198. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/asn1/LICENSE +19 -0
  199. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/asn1/README.md +50 -0
  200. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/asn1/lib/ber/errors.js +13 -0
  201. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/asn1/lib/ber/index.js +27 -0
  202. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/asn1/lib/ber/reader.js +267 -0
  203. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/asn1/lib/ber/types.js +36 -0
  204. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/asn1/lib/ber/writer.js +317 -0
  205. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/asn1/lib/index.js +20 -0
  206. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/asn1/package.json +63 -0
  207. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/asn1/tst/ber/reader.test.js +172 -0
  208. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/asn1/tst/ber/writer.test.js +296 -0
  209. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/assert-plus/README.md +126 -0
  210. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/assert-plus/assert.js +245 -0
  211. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/assert-plus/package.json +45 -0
  212. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/ctype/.npmignore +1 -0
  213. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/ctype/CHANGELOG +78 -0
  214. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/ctype/LICENSE +24 -0
  215. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/ctype/README +82 -0
  216. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/ctype/README.old +298 -0
  217. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/ctype/ctf.js +245 -0
  218. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/ctype/ctio.js +1485 -0
  219. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/ctype/ctype.js +944 -0
  220. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/ctype/man/man3ctype/ctio.3ctype +241 -0
  221. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/ctype/package.json +42 -0
  222. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/ctype/tools/jsl.conf +129 -0
  223. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/ctype/tools/jsstyle +839 -0
  224. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/package.json +72 -0
  225. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/json-stringify-safe/.npmignore +1 -0
  226. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/json-stringify-safe/CHANGELOG.md +14 -0
  227. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/json-stringify-safe/LICENSE +15 -0
  228. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/json-stringify-safe/Makefile +35 -0
  229. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/json-stringify-safe/README.md +52 -0
  230. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/json-stringify-safe/package.json +68 -0
  231. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/json-stringify-safe/stringify.js +27 -0
  232. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/json-stringify-safe/test/mocha.opts +2 -0
  233. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/json-stringify-safe/test/stringify_test.js +246 -0
  234. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/mime/LICENSE +19 -0
  235. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/mime/README.md +66 -0
  236. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/mime/mime.js +114 -0
  237. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/mime/package.json +57 -0
  238. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/mime/test.js +84 -0
  239. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/mime/types/mime.types +1588 -0
  240. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/mime/types/node.types +77 -0
  241. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/node-uuid/.npmignore +2 -0
  242. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/node-uuid/LICENSE.md +21 -0
  243. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/node-uuid/README.md +243 -0
  244. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/node-uuid/benchmark/README.md +53 -0
  245. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/node-uuid/benchmark/bench.gnu +174 -0
  246. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/node-uuid/benchmark/bench.sh +34 -0
  247. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/node-uuid/benchmark/benchmark-native.c +34 -0
  248. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/node-uuid/benchmark/benchmark.js +84 -0
  249. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/node-uuid/bin/uuid +26 -0
  250. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/node-uuid/bower.json +23 -0
  251. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/node-uuid/component.json +18 -0
  252. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/node-uuid/package.json +65 -0
  253. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/node-uuid/test/compare_v1.js +63 -0
  254. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/node-uuid/test/test.html +17 -0
  255. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/node-uuid/test/test.js +228 -0
  256. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/node-uuid/uuid.js +247 -0
  257. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/oauth-sign/LICENSE +55 -0
  258. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/oauth-sign/README.md +4 -0
  259. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/oauth-sign/index.js +43 -0
  260. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/oauth-sign/package.json +48 -0
  261. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/oauth-sign/test.js +49 -0
  262. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/qs/.gitmodules +6 -0
  263. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/qs/.npmignore +7 -0
  264. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/qs/Readme.md +58 -0
  265. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/qs/index.js +366 -0
  266. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/qs/package.json +55 -0
  267. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/tough-cookie/.jshintrc +72 -0
  268. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/tough-cookie/.npmignore +3 -0
  269. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/tough-cookie/LICENSE +78 -0
  270. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/tough-cookie/README.md +380 -0
  271. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/tough-cookie/generate-pubsuffix.js +230 -0
  272. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/tough-cookie/lib/cookie.js +947 -0
  273. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/tough-cookie/lib/memstore.js +102 -0
  274. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/tough-cookie/lib/pubsuffix.js +69 -0
  275. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/tough-cookie/node_modules/punycode/LICENSE-MIT.txt +20 -0
  276. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/tough-cookie/node_modules/punycode/README.md +176 -0
  277. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/tough-cookie/node_modules/punycode/package.json +81 -0
  278. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/tough-cookie/node_modules/punycode/punycode.js +530 -0
  279. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/tough-cookie/package.json +63 -0
  280. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/tough-cookie/public-suffix.txt +5229 -0
  281. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/tough-cookie/test.js +1340 -0
  282. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/tunnel-agent/LICENSE +55 -0
  283. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/tunnel-agent/README.md +4 -0
  284. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/tunnel-agent/index.js +227 -0
  285. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/tunnel-agent/package.json +45 -0
  286. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/package.json +74 -0
  287. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/request.js +1244 -0
  288. data/node_modules/freezerwatch/node_modules/lacrosse/package.json +34 -0
  289. data/node_modules/freezerwatch/node_modules/optparse/README.md +163 -0
  290. data/node_modules/freezerwatch/node_modules/optparse/TODO +1 -0
  291. data/node_modules/freezerwatch/node_modules/optparse/examples/browser-test.html +75 -0
  292. data/node_modules/freezerwatch/node_modules/optparse/examples/nodejs-test.js +86 -0
  293. data/node_modules/freezerwatch/node_modules/optparse/lib/optparse.js +309 -0
  294. data/node_modules/freezerwatch/node_modules/optparse/package.json +46 -0
  295. data/node_modules/freezerwatch/node_modules/optparse/seed.yml +5 -0
  296. data/node_modules/freezerwatch/node_modules/osenv/.npmignore +13 -0
  297. data/node_modules/freezerwatch/node_modules/osenv/.travis.yml +9 -0
  298. data/node_modules/freezerwatch/node_modules/osenv/LICENSE +15 -0
  299. data/node_modules/freezerwatch/node_modules/osenv/README.md +63 -0
  300. data/node_modules/freezerwatch/node_modules/osenv/node_modules/os-homedir/index.js +24 -0
  301. data/node_modules/freezerwatch/node_modules/osenv/node_modules/os-homedir/license +21 -0
  302. data/node_modules/freezerwatch/node_modules/osenv/node_modules/os-homedir/package.json +70 -0
  303. data/node_modules/freezerwatch/node_modules/osenv/node_modules/os-homedir/readme.md +33 -0
  304. data/node_modules/freezerwatch/node_modules/osenv/node_modules/os-tmpdir/index.js +25 -0
  305. data/node_modules/freezerwatch/node_modules/osenv/node_modules/os-tmpdir/license +21 -0
  306. data/node_modules/freezerwatch/node_modules/osenv/node_modules/os-tmpdir/package.json +70 -0
  307. data/node_modules/freezerwatch/node_modules/osenv/node_modules/os-tmpdir/readme.md +36 -0
  308. data/node_modules/freezerwatch/node_modules/osenv/osenv.js +72 -0
  309. data/node_modules/freezerwatch/node_modules/osenv/package.json +76 -0
  310. data/node_modules/freezerwatch/node_modules/osenv/test/unix.js +71 -0
  311. data/node_modules/freezerwatch/node_modules/osenv/test/windows.js +74 -0
  312. data/node_modules/freezerwatch/node_modules/osenv/x.tap +39 -0
  313. data/node_modules/freezerwatch/package.json +37 -0
  314. metadata +384 -0
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2010-2014 Caolan McMahon
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
@@ -0,0 +1,1647 @@
1
+ # Async.js
2
+
3
+ [![Build Status via Travis CI](https://travis-ci.org/caolan/async.svg?branch=master)](https://travis-ci.org/caolan/async)
4
+
5
+
6
+ Async is a utility module which provides straight-forward, powerful functions
7
+ for working with asynchronous JavaScript. Although originally designed for
8
+ use with [Node.js](http://nodejs.org) and installable via `npm install async`,
9
+ it can also be used directly in the browser.
10
+
11
+ Async is also installable via:
12
+
13
+ - [bower](http://bower.io/): `bower install async`
14
+ - [component](https://github.com/component/component): `component install
15
+ caolan/async`
16
+ - [jam](http://jamjs.org/): `jam install async`
17
+ - [spm](http://spmjs.io/): `spm install async`
18
+
19
+ Async provides around 20 functions that include the usual 'functional'
20
+ suspects (`map`, `reduce`, `filter`, `each`…) as well as some common patterns
21
+ for asynchronous control flow (`parallel`, `series`, `waterfall`…). All these
22
+ functions assume you follow the Node.js convention of providing a single
23
+ callback as the last argument of your `async` function.
24
+
25
+
26
+ ## Quick Examples
27
+
28
+ ```javascript
29
+ async.map(['file1','file2','file3'], fs.stat, function(err, results){
30
+ // results is now an array of stats for each file
31
+ });
32
+
33
+ async.filter(['file1','file2','file3'], fs.exists, function(results){
34
+ // results now equals an array of the existing files
35
+ });
36
+
37
+ async.parallel([
38
+ function(){ ... },
39
+ function(){ ... }
40
+ ], callback);
41
+
42
+ async.series([
43
+ function(){ ... },
44
+ function(){ ... }
45
+ ]);
46
+ ```
47
+
48
+ There are many more functions available so take a look at the docs below for a
49
+ full list. This module aims to be comprehensive, so if you feel anything is
50
+ missing please create a GitHub issue for it.
51
+
52
+ ## Common Pitfalls
53
+
54
+ ### Binding a context to an iterator
55
+
56
+ This section is really about `bind`, not about `async`. If you are wondering how to
57
+ make `async` execute your iterators in a given context, or are confused as to why
58
+ a method of another library isn't working as an iterator, study this example:
59
+
60
+ ```js
61
+ // Here is a simple object with an (unnecessarily roundabout) squaring method
62
+ var AsyncSquaringLibrary = {
63
+ squareExponent: 2,
64
+ square: function(number, callback){
65
+ var result = Math.pow(number, this.squareExponent);
66
+ setTimeout(function(){
67
+ callback(null, result);
68
+ }, 200);
69
+ }
70
+ };
71
+
72
+ async.map([1, 2, 3], AsyncSquaringLibrary.square, function(err, result){
73
+ // result is [NaN, NaN, NaN]
74
+ // This fails because the `this.squareExponent` expression in the square
75
+ // function is not evaluated in the context of AsyncSquaringLibrary, and is
76
+ // therefore undefined.
77
+ });
78
+
79
+ async.map([1, 2, 3], AsyncSquaringLibrary.square.bind(AsyncSquaringLibrary), function(err, result){
80
+ // result is [1, 4, 9]
81
+ // With the help of bind we can attach a context to the iterator before
82
+ // passing it to async. Now the square function will be executed in its
83
+ // 'home' AsyncSquaringLibrary context and the value of `this.squareExponent`
84
+ // will be as expected.
85
+ });
86
+ ```
87
+
88
+ ## Download
89
+
90
+ The source is available for download from
91
+ [GitHub](http://github.com/caolan/async).
92
+ Alternatively, you can install using Node Package Manager (`npm`):
93
+
94
+ npm install async
95
+
96
+ __Development:__ [async.js](https://github.com/caolan/async/raw/master/lib/async.js) - 29.6kb Uncompressed
97
+
98
+ ## In the Browser
99
+
100
+ So far it's been tested in IE6, IE7, IE8, FF3.6 and Chrome 5.
101
+
102
+ Usage:
103
+
104
+ ```html
105
+ <script type="text/javascript" src="async.js"></script>
106
+ <script type="text/javascript">
107
+
108
+ async.map(data, asyncProcess, function(err, results){
109
+ alert(results);
110
+ });
111
+
112
+ </script>
113
+ ```
114
+
115
+ ## Documentation
116
+
117
+ ### Collections
118
+
119
+ * [`each`](#each)
120
+ * [`eachSeries`](#eachSeries)
121
+ * [`eachLimit`](#eachLimit)
122
+ * [`map`](#map)
123
+ * [`mapSeries`](#mapSeries)
124
+ * [`mapLimit`](#mapLimit)
125
+ * [`filter`](#filter)
126
+ * [`filterSeries`](#filterSeries)
127
+ * [`reject`](#reject)
128
+ * [`rejectSeries`](#rejectSeries)
129
+ * [`reduce`](#reduce)
130
+ * [`reduceRight`](#reduceRight)
131
+ * [`detect`](#detect)
132
+ * [`detectSeries`](#detectSeries)
133
+ * [`sortBy`](#sortBy)
134
+ * [`some`](#some)
135
+ * [`every`](#every)
136
+ * [`concat`](#concat)
137
+ * [`concatSeries`](#concatSeries)
138
+
139
+ ### Control Flow
140
+
141
+ * [`series`](#seriestasks-callback)
142
+ * [`parallel`](#parallel)
143
+ * [`parallelLimit`](#parallellimittasks-limit-callback)
144
+ * [`whilst`](#whilst)
145
+ * [`doWhilst`](#doWhilst)
146
+ * [`until`](#until)
147
+ * [`doUntil`](#doUntil)
148
+ * [`forever`](#forever)
149
+ * [`waterfall`](#waterfall)
150
+ * [`compose`](#compose)
151
+ * [`seq`](#seq)
152
+ * [`applyEach`](#applyEach)
153
+ * [`applyEachSeries`](#applyEachSeries)
154
+ * [`queue`](#queue)
155
+ * [`priorityQueue`](#priorityQueue)
156
+ * [`cargo`](#cargo)
157
+ * [`auto`](#auto)
158
+ * [`retry`](#retry)
159
+ * [`iterator`](#iterator)
160
+ * [`apply`](#apply)
161
+ * [`nextTick`](#nextTick)
162
+ * [`times`](#times)
163
+ * [`timesSeries`](#timesSeries)
164
+
165
+ ### Utils
166
+
167
+ * [`memoize`](#memoize)
168
+ * [`unmemoize`](#unmemoize)
169
+ * [`log`](#log)
170
+ * [`dir`](#dir)
171
+ * [`noConflict`](#noConflict)
172
+
173
+
174
+ ## Collections
175
+
176
+ <a name="forEach" />
177
+ <a name="each" />
178
+ ### each(arr, iterator, callback)
179
+
180
+ Applies the function `iterator` to each item in `arr`, in parallel.
181
+ The `iterator` is called with an item from the list, and a callback for when it
182
+ has finished. If the `iterator` passes an error to its `callback`, the main
183
+ `callback` (for the `each` function) is immediately called with the error.
184
+
185
+ Note, that since this function applies `iterator` to each item in parallel,
186
+ there is no guarantee that the iterator functions will complete in order.
187
+
188
+ __Arguments__
189
+
190
+ * `arr` - An array to iterate over.
191
+ * `iterator(item, callback)` - A function to apply to each item in `arr`.
192
+ The iterator is passed a `callback(err)` which must be called once it has
193
+ completed. If no error has occurred, the `callback` should be run without
194
+ arguments or with an explicit `null` argument.
195
+ * `callback(err)` - A callback which is called when all `iterator` functions
196
+ have finished, or an error occurs.
197
+
198
+ __Examples__
199
+
200
+
201
+ ```js
202
+ // assuming openFiles is an array of file names and saveFile is a function
203
+ // to save the modified contents of that file:
204
+
205
+ async.each(openFiles, saveFile, function(err){
206
+ // if any of the saves produced an error, err would equal that error
207
+ });
208
+ ```
209
+
210
+ ```js
211
+ // assuming openFiles is an array of file names
212
+
213
+ async.each(openFiles, function(file, callback) {
214
+
215
+ // Perform operation on file here.
216
+ console.log('Processing file ' + file);
217
+
218
+ if( file.length > 32 ) {
219
+ console.log('This file name is too long');
220
+ callback('File name too long');
221
+ } else {
222
+ // Do work to process file here
223
+ console.log('File processed');
224
+ callback();
225
+ }
226
+ }, function(err){
227
+ // if any of the file processing produced an error, err would equal that error
228
+ if( err ) {
229
+ // One of the iterations produced an error.
230
+ // All processing will now stop.
231
+ console.log('A file failed to process');
232
+ } else {
233
+ console.log('All files have been processed successfully');
234
+ }
235
+ });
236
+ ```
237
+
238
+ ---------------------------------------
239
+
240
+ <a name="forEachSeries" />
241
+ <a name="eachSeries" />
242
+ ### eachSeries(arr, iterator, callback)
243
+
244
+ The same as [`each`](#each), only `iterator` is applied to each item in `arr` in
245
+ series. The next `iterator` is only called once the current one has completed.
246
+ This means the `iterator` functions will complete in order.
247
+
248
+
249
+ ---------------------------------------
250
+
251
+ <a name="forEachLimit" />
252
+ <a name="eachLimit" />
253
+ ### eachLimit(arr, limit, iterator, callback)
254
+
255
+ The same as [`each`](#each), only no more than `limit` `iterator`s will be simultaneously
256
+ running at any time.
257
+
258
+ Note that the items in `arr` are not processed in batches, so there is no guarantee that
259
+ the first `limit` `iterator` functions will complete before any others are started.
260
+
261
+ __Arguments__
262
+
263
+ * `arr` - An array to iterate over.
264
+ * `limit` - The maximum number of `iterator`s to run at any time.
265
+ * `iterator(item, callback)` - A function to apply to each item in `arr`.
266
+ The iterator is passed a `callback(err)` which must be called once it has
267
+ completed. If no error has occurred, the callback should be run without
268
+ arguments or with an explicit `null` argument.
269
+ * `callback(err)` - A callback which is called when all `iterator` functions
270
+ have finished, or an error occurs.
271
+
272
+ __Example__
273
+
274
+ ```js
275
+ // Assume documents is an array of JSON objects and requestApi is a
276
+ // function that interacts with a rate-limited REST api.
277
+
278
+ async.eachLimit(documents, 20, requestApi, function(err){
279
+ // if any of the saves produced an error, err would equal that error
280
+ });
281
+ ```
282
+
283
+ ---------------------------------------
284
+
285
+ <a name="map" />
286
+ ### map(arr, iterator, callback)
287
+
288
+ Produces a new array of values by mapping each value in `arr` through
289
+ the `iterator` function. The `iterator` is called with an item from `arr` and a
290
+ callback for when it has finished processing. Each of these callback takes 2 arguments:
291
+ an `error`, and the transformed item from `arr`. If `iterator` passes an error to his
292
+ callback, the main `callback` (for the `map` function) is immediately called with the error.
293
+
294
+ Note, that since this function applies the `iterator` to each item in parallel,
295
+ there is no guarantee that the `iterator` functions will complete in order.
296
+ However, the results array will be in the same order as the original `arr`.
297
+
298
+ __Arguments__
299
+
300
+ * `arr` - An array to iterate over.
301
+ * `iterator(item, callback)` - A function to apply to each item in `arr`.
302
+ The iterator is passed a `callback(err, transformed)` which must be called once
303
+ it has completed with an error (which can be `null`) and a transformed item.
304
+ * `callback(err, results)` - A callback which is called when all `iterator`
305
+ functions have finished, or an error occurs. Results is an array of the
306
+ transformed items from the `arr`.
307
+
308
+ __Example__
309
+
310
+ ```js
311
+ async.map(['file1','file2','file3'], fs.stat, function(err, results){
312
+ // results is now an array of stats for each file
313
+ });
314
+ ```
315
+
316
+ ---------------------------------------
317
+
318
+ <a name="mapSeries" />
319
+ ### mapSeries(arr, iterator, callback)
320
+
321
+ The same as [`map`](#map), only the `iterator` is applied to each item in `arr` in
322
+ series. The next `iterator` is only called once the current one has completed.
323
+ The results array will be in the same order as the original.
324
+
325
+
326
+ ---------------------------------------
327
+
328
+ <a name="mapLimit" />
329
+ ### mapLimit(arr, limit, iterator, callback)
330
+
331
+ The same as [`map`](#map), only no more than `limit` `iterator`s will be simultaneously
332
+ running at any time.
333
+
334
+ Note that the items are not processed in batches, so there is no guarantee that
335
+ the first `limit` `iterator` functions will complete before any others are started.
336
+
337
+ __Arguments__
338
+
339
+ * `arr` - An array to iterate over.
340
+ * `limit` - The maximum number of `iterator`s to run at any time.
341
+ * `iterator(item, callback)` - A function to apply to each item in `arr`.
342
+ The iterator is passed a `callback(err, transformed)` which must be called once
343
+ it has completed with an error (which can be `null`) and a transformed item.
344
+ * `callback(err, results)` - A callback which is called when all `iterator`
345
+ calls have finished, or an error occurs. The result is an array of the
346
+ transformed items from the original `arr`.
347
+
348
+ __Example__
349
+
350
+ ```js
351
+ async.mapLimit(['file1','file2','file3'], 1, fs.stat, function(err, results){
352
+ // results is now an array of stats for each file
353
+ });
354
+ ```
355
+
356
+ ---------------------------------------
357
+
358
+ <a name="select" />
359
+ <a name="filter" />
360
+ ### filter(arr, iterator, callback)
361
+
362
+ __Alias:__ `select`
363
+
364
+ Returns a new array of all the values in `arr` which pass an async truth test.
365
+ _The callback for each `iterator` call only accepts a single argument of `true` or
366
+ `false`; it does not accept an error argument first!_ This is in-line with the
367
+ way node libraries work with truth tests like `fs.exists`. This operation is
368
+ performed in parallel, but the results array will be in the same order as the
369
+ original.
370
+
371
+ __Arguments__
372
+
373
+ * `arr` - An array to iterate over.
374
+ * `iterator(item, callback)` - A truth test to apply to each item in `arr`.
375
+ The `iterator` is passed a `callback(truthValue)`, which must be called with a
376
+ boolean argument once it has completed.
377
+ * `callback(results)` - A callback which is called after all the `iterator`
378
+ functions have finished.
379
+
380
+ __Example__
381
+
382
+ ```js
383
+ async.filter(['file1','file2','file3'], fs.exists, function(results){
384
+ // results now equals an array of the existing files
385
+ });
386
+ ```
387
+
388
+ ---------------------------------------
389
+
390
+ <a name="selectSeries" />
391
+ <a name="filterSeries" />
392
+ ### filterSeries(arr, iterator, callback)
393
+
394
+ __Alias:__ `selectSeries`
395
+
396
+ The same as [`filter`](#filter) only the `iterator` is applied to each item in `arr` in
397
+ series. The next `iterator` is only called once the current one has completed.
398
+ The results array will be in the same order as the original.
399
+
400
+ ---------------------------------------
401
+
402
+ <a name="reject" />
403
+ ### reject(arr, iterator, callback)
404
+
405
+ The opposite of [`filter`](#filter). Removes values that pass an `async` truth test.
406
+
407
+ ---------------------------------------
408
+
409
+ <a name="rejectSeries" />
410
+ ### rejectSeries(arr, iterator, callback)
411
+
412
+ The same as [`reject`](#reject), only the `iterator` is applied to each item in `arr`
413
+ in series.
414
+
415
+
416
+ ---------------------------------------
417
+
418
+ <a name="reduce" />
419
+ ### reduce(arr, memo, iterator, callback)
420
+
421
+ __Aliases:__ `inject`, `foldl`
422
+
423
+ Reduces `arr` into a single value using an async `iterator` to return
424
+ each successive step. `memo` is the initial state of the reduction.
425
+ This function only operates in series.
426
+
427
+ For performance reasons, it may make sense to split a call to this function into
428
+ a parallel map, and then use the normal `Array.prototype.reduce` on the results.
429
+ This function is for situations where each step in the reduction needs to be async;
430
+ if you can get the data before reducing it, then it's probably a good idea to do so.
431
+
432
+ __Arguments__
433
+
434
+ * `arr` - An array to iterate over.
435
+ * `memo` - The initial state of the reduction.
436
+ * `iterator(memo, item, callback)` - A function applied to each item in the
437
+ array to produce the next step in the reduction. The `iterator` is passed a
438
+ `callback(err, reduction)` which accepts an optional error as its first
439
+ argument, and the state of the reduction as the second. If an error is
440
+ passed to the callback, the reduction is stopped and the main `callback` is
441
+ immediately called with the error.
442
+ * `callback(err, result)` - A callback which is called after all the `iterator`
443
+ functions have finished. Result is the reduced value.
444
+
445
+ __Example__
446
+
447
+ ```js
448
+ async.reduce([1,2,3], 0, function(memo, item, callback){
449
+ // pointless async:
450
+ process.nextTick(function(){
451
+ callback(null, memo + item)
452
+ });
453
+ }, function(err, result){
454
+ // result is now equal to the last value of memo, which is 6
455
+ });
456
+ ```
457
+
458
+ ---------------------------------------
459
+
460
+ <a name="reduceRight" />
461
+ ### reduceRight(arr, memo, iterator, callback)
462
+
463
+ __Alias:__ `foldr`
464
+
465
+ Same as [`reduce`](#reduce), only operates on `arr` in reverse order.
466
+
467
+
468
+ ---------------------------------------
469
+
470
+ <a name="detect" />
471
+ ### detect(arr, iterator, callback)
472
+
473
+ Returns the first value in `arr` that passes an async truth test. The
474
+ `iterator` is applied in parallel, meaning the first iterator to return `true` will
475
+ fire the detect `callback` with that result. That means the result might not be
476
+ the first item in the original `arr` (in terms of order) that passes the test.
477
+
478
+ If order within the original `arr` is important, then look at [`detectSeries`](#detectSeries).
479
+
480
+ __Arguments__
481
+
482
+ * `arr` - An array to iterate over.
483
+ * `iterator(item, callback)` - A truth test to apply to each item in `arr`.
484
+ The iterator is passed a `callback(truthValue)` which must be called with a
485
+ boolean argument once it has completed.
486
+ * `callback(result)` - A callback which is called as soon as any iterator returns
487
+ `true`, or after all the `iterator` functions have finished. Result will be
488
+ the first item in the array that passes the truth test (iterator) or the
489
+ value `undefined` if none passed.
490
+
491
+ __Example__
492
+
493
+ ```js
494
+ async.detect(['file1','file2','file3'], fs.exists, function(result){
495
+ // result now equals the first file in the list that exists
496
+ });
497
+ ```
498
+
499
+ ---------------------------------------
500
+
501
+ <a name="detectSeries" />
502
+ ### detectSeries(arr, iterator, callback)
503
+
504
+ The same as [`detect`](#detect), only the `iterator` is applied to each item in `arr`
505
+ in series. This means the result is always the first in the original `arr` (in
506
+ terms of array order) that passes the truth test.
507
+
508
+
509
+ ---------------------------------------
510
+
511
+ <a name="sortBy" />
512
+ ### sortBy(arr, iterator, callback)
513
+
514
+ Sorts a list by the results of running each `arr` value through an async `iterator`.
515
+
516
+ __Arguments__
517
+
518
+ * `arr` - An array to iterate over.
519
+ * `iterator(item, callback)` - A function to apply to each item in `arr`.
520
+ The iterator is passed a `callback(err, sortValue)` which must be called once it
521
+ has completed with an error (which can be `null`) and a value to use as the sort
522
+ criteria.
523
+ * `callback(err, results)` - A callback which is called after all the `iterator`
524
+ functions have finished, or an error occurs. Results is the items from
525
+ the original `arr` sorted by the values returned by the `iterator` calls.
526
+
527
+ __Example__
528
+
529
+ ```js
530
+ async.sortBy(['file1','file2','file3'], function(file, callback){
531
+ fs.stat(file, function(err, stats){
532
+ callback(err, stats.mtime);
533
+ });
534
+ }, function(err, results){
535
+ // results is now the original array of files sorted by
536
+ // modified date
537
+ });
538
+ ```
539
+
540
+ __Sort Order__
541
+
542
+ By modifying the callback parameter the sorting order can be influenced:
543
+
544
+ ```js
545
+ //ascending order
546
+ async.sortBy([1,9,3,5], function(x, callback){
547
+ callback(null, x);
548
+ }, function(err,result){
549
+ //result callback
550
+ } );
551
+
552
+ //descending order
553
+ async.sortBy([1,9,3,5], function(x, callback){
554
+ callback(null, x*-1); //<- x*-1 instead of x, turns the order around
555
+ }, function(err,result){
556
+ //result callback
557
+ } );
558
+ ```
559
+
560
+ ---------------------------------------
561
+
562
+ <a name="some" />
563
+ ### some(arr, iterator, callback)
564
+
565
+ __Alias:__ `any`
566
+
567
+ Returns `true` if at least one element in the `arr` satisfies an async test.
568
+ _The callback for each iterator call only accepts a single argument of `true` or
569
+ `false`; it does not accept an error argument first!_ This is in-line with the
570
+ way node libraries work with truth tests like `fs.exists`. Once any iterator
571
+ call returns `true`, the main `callback` is immediately called.
572
+
573
+ __Arguments__
574
+
575
+ * `arr` - An array to iterate over.
576
+ * `iterator(item, callback)` - A truth test to apply to each item in the array
577
+ in parallel. The iterator is passed a callback(truthValue) which must be
578
+ called with a boolean argument once it has completed.
579
+ * `callback(result)` - A callback which is called as soon as any iterator returns
580
+ `true`, or after all the iterator functions have finished. Result will be
581
+ either `true` or `false` depending on the values of the async tests.
582
+
583
+ __Example__
584
+
585
+ ```js
586
+ async.some(['file1','file2','file3'], fs.exists, function(result){
587
+ // if result is true then at least one of the files exists
588
+ });
589
+ ```
590
+
591
+ ---------------------------------------
592
+
593
+ <a name="every" />
594
+ ### every(arr, iterator, callback)
595
+
596
+ __Alias:__ `all`
597
+
598
+ Returns `true` if every element in `arr` satisfies an async test.
599
+ _The callback for each `iterator` call only accepts a single argument of `true` or
600
+ `false`; it does not accept an error argument first!_ This is in-line with the
601
+ way node libraries work with truth tests like `fs.exists`.
602
+
603
+ __Arguments__
604
+
605
+ * `arr` - An array to iterate over.
606
+ * `iterator(item, callback)` - A truth test to apply to each item in the array
607
+ in parallel. The iterator is passed a callback(truthValue) which must be
608
+ called with a boolean argument once it has completed.
609
+ * `callback(result)` - A callback which is called after all the `iterator`
610
+ functions have finished. Result will be either `true` or `false` depending on
611
+ the values of the async tests.
612
+
613
+ __Example__
614
+
615
+ ```js
616
+ async.every(['file1','file2','file3'], fs.exists, function(result){
617
+ // if result is true then every file exists
618
+ });
619
+ ```
620
+
621
+ ---------------------------------------
622
+
623
+ <a name="concat" />
624
+ ### concat(arr, iterator, callback)
625
+
626
+ Applies `iterator` to each item in `arr`, concatenating the results. Returns the
627
+ concatenated list. The `iterator`s are called in parallel, and the results are
628
+ concatenated as they return. There is no guarantee that the results array will
629
+ be returned in the original order of `arr` passed to the `iterator` function.
630
+
631
+ __Arguments__
632
+
633
+ * `arr` - An array to iterate over.
634
+ * `iterator(item, callback)` - A function to apply to each item in `arr`.
635
+ The iterator is passed a `callback(err, results)` which must be called once it
636
+ has completed with an error (which can be `null`) and an array of results.
637
+ * `callback(err, results)` - A callback which is called after all the `iterator`
638
+ functions have finished, or an error occurs. Results is an array containing
639
+ the concatenated results of the `iterator` function.
640
+
641
+ __Example__
642
+
643
+ ```js
644
+ async.concat(['dir1','dir2','dir3'], fs.readdir, function(err, files){
645
+ // files is now a list of filenames that exist in the 3 directories
646
+ });
647
+ ```
648
+
649
+ ---------------------------------------
650
+
651
+ <a name="concatSeries" />
652
+ ### concatSeries(arr, iterator, callback)
653
+
654
+ Same as [`concat`](#concat), but executes in series instead of parallel.
655
+
656
+
657
+ ## Control Flow
658
+
659
+ <a name="series" />
660
+ ### series(tasks, [callback])
661
+
662
+ Run the functions in the `tasks` array in series, each one running once the previous
663
+ function has completed. If any functions in the series pass an error to its
664
+ callback, no more functions are run, and `callback` is immediately called with the value of the error.
665
+ Otherwise, `callback` receives an array of results when `tasks` have completed.
666
+
667
+ It is also possible to use an object instead of an array. Each property will be
668
+ run as a function, and the results will be passed to the final `callback` as an object
669
+ instead of an array. This can be a more readable way of handling results from
670
+ [`series`](#series).
671
+
672
+ **Note** that while many implementations preserve the order of object properties, the
673
+ [ECMAScript Language Specifcation](http://www.ecma-international.org/ecma-262/5.1/#sec-8.6)
674
+ explicitly states that
675
+
676
+ > The mechanics and order of enumerating the properties is not specified.
677
+
678
+ So if you rely on the order in which your series of functions are executed, and want
679
+ this to work on all platforms, consider using an array.
680
+
681
+ __Arguments__
682
+
683
+ * `tasks` - An array or object containing functions to run, each function is passed
684
+ a `callback(err, result)` it must call on completion with an error `err` (which can
685
+ be `null`) and an optional `result` value.
686
+ * `callback(err, results)` - An optional callback to run once all the functions
687
+ have completed. This function gets a results array (or object) containing all
688
+ the result arguments passed to the `task` callbacks.
689
+
690
+ __Example__
691
+
692
+ ```js
693
+ async.series([
694
+ function(callback){
695
+ // do some stuff ...
696
+ callback(null, 'one');
697
+ },
698
+ function(callback){
699
+ // do some more stuff ...
700
+ callback(null, 'two');
701
+ }
702
+ ],
703
+ // optional callback
704
+ function(err, results){
705
+ // results is now equal to ['one', 'two']
706
+ });
707
+
708
+
709
+ // an example using an object instead of an array
710
+ async.series({
711
+ one: function(callback){
712
+ setTimeout(function(){
713
+ callback(null, 1);
714
+ }, 200);
715
+ },
716
+ two: function(callback){
717
+ setTimeout(function(){
718
+ callback(null, 2);
719
+ }, 100);
720
+ }
721
+ },
722
+ function(err, results) {
723
+ // results is now equal to: {one: 1, two: 2}
724
+ });
725
+ ```
726
+
727
+ ---------------------------------------
728
+
729
+ <a name="parallel" />
730
+ ### parallel(tasks, [callback])
731
+
732
+ Run the `tasks` array of functions in parallel, without waiting until the previous
733
+ function has completed. If any of the functions pass an error to its
734
+ callback, the main `callback` is immediately called with the value of the error.
735
+ Once the `tasks` have completed, the results are passed to the final `callback` as an
736
+ array.
737
+
738
+ It is also possible to use an object instead of an array. Each property will be
739
+ run as a function and the results will be passed to the final `callback` as an object
740
+ instead of an array. This can be a more readable way of handling results from
741
+ [`parallel`](#parallel).
742
+
743
+
744
+ __Arguments__
745
+
746
+ * `tasks` - An array or object containing functions to run. Each function is passed
747
+ a `callback(err, result)` which it must call on completion with an error `err`
748
+ (which can be `null`) and an optional `result` value.
749
+ * `callback(err, results)` - An optional callback to run once all the functions
750
+ have completed. This function gets a results array (or object) containing all
751
+ the result arguments passed to the task callbacks.
752
+
753
+ __Example__
754
+
755
+ ```js
756
+ async.parallel([
757
+ function(callback){
758
+ setTimeout(function(){
759
+ callback(null, 'one');
760
+ }, 200);
761
+ },
762
+ function(callback){
763
+ setTimeout(function(){
764
+ callback(null, 'two');
765
+ }, 100);
766
+ }
767
+ ],
768
+ // optional callback
769
+ function(err, results){
770
+ // the results array will equal ['one','two'] even though
771
+ // the second function had a shorter timeout.
772
+ });
773
+
774
+
775
+ // an example using an object instead of an array
776
+ async.parallel({
777
+ one: function(callback){
778
+ setTimeout(function(){
779
+ callback(null, 1);
780
+ }, 200);
781
+ },
782
+ two: function(callback){
783
+ setTimeout(function(){
784
+ callback(null, 2);
785
+ }, 100);
786
+ }
787
+ },
788
+ function(err, results) {
789
+ // results is now equals to: {one: 1, two: 2}
790
+ });
791
+ ```
792
+
793
+ ---------------------------------------
794
+
795
+ <a name="parallelLimit" />
796
+ ### parallelLimit(tasks, limit, [callback])
797
+
798
+ The same as [`parallel`](#parallel), only `tasks` are executed in parallel
799
+ with a maximum of `limit` tasks executing at any time.
800
+
801
+ Note that the `tasks` are not executed in batches, so there is no guarantee that
802
+ the first `limit` tasks will complete before any others are started.
803
+
804
+ __Arguments__
805
+
806
+ * `tasks` - An array or object containing functions to run, each function is passed
807
+ a `callback(err, result)` it must call on completion with an error `err` (which can
808
+ be `null`) and an optional `result` value.
809
+ * `limit` - The maximum number of `tasks` to run at any time.
810
+ * `callback(err, results)` - An optional callback to run once all the functions
811
+ have completed. This function gets a results array (or object) containing all
812
+ the result arguments passed to the `task` callbacks.
813
+
814
+ ---------------------------------------
815
+
816
+ <a name="whilst" />
817
+ ### whilst(test, fn, callback)
818
+
819
+ Repeatedly call `fn`, while `test` returns `true`. Calls `callback` when stopped,
820
+ or an error occurs.
821
+
822
+ __Arguments__
823
+
824
+ * `test()` - synchronous truth test to perform before each execution of `fn`.
825
+ * `fn(callback)` - A function which is called each time `test` passes. The function is
826
+ passed a `callback(err)`, which must be called once it has completed with an
827
+ optional `err` argument.
828
+ * `callback(err)` - A callback which is called after the test fails and repeated
829
+ execution of `fn` has stopped.
830
+
831
+ __Example__
832
+
833
+ ```js
834
+ var count = 0;
835
+
836
+ async.whilst(
837
+ function () { return count < 5; },
838
+ function (callback) {
839
+ count++;
840
+ setTimeout(callback, 1000);
841
+ },
842
+ function (err) {
843
+ // 5 seconds have passed
844
+ }
845
+ );
846
+ ```
847
+
848
+ ---------------------------------------
849
+
850
+ <a name="doWhilst" />
851
+ ### doWhilst(fn, test, callback)
852
+
853
+ The post-check version of [`whilst`](#whilst). To reflect the difference in
854
+ the order of operations, the arguments `test` and `fn` are switched.
855
+
856
+ `doWhilst` is to `whilst` as `do while` is to `while` in plain JavaScript.
857
+
858
+ ---------------------------------------
859
+
860
+ <a name="until" />
861
+ ### until(test, fn, callback)
862
+
863
+ Repeatedly call `fn` until `test` returns `true`. Calls `callback` when stopped,
864
+ or an error occurs.
865
+
866
+ The inverse of [`whilst`](#whilst).
867
+
868
+ ---------------------------------------
869
+
870
+ <a name="doUntil" />
871
+ ### doUntil(fn, test, callback)
872
+
873
+ Like [`doWhilst`](#doWhilst), except the `test` is inverted. Note the argument ordering differs from `until`.
874
+
875
+ ---------------------------------------
876
+
877
+ <a name="forever" />
878
+ ### forever(fn, errback)
879
+
880
+ Calls the asynchronous function `fn` with a callback parameter that allows it to
881
+ call itself again, in series, indefinitely.
882
+
883
+ If an error is passed to the callback then `errback` is called with the
884
+ error, and execution stops, otherwise it will never be called.
885
+
886
+ ```js
887
+ async.forever(
888
+ function(next) {
889
+ // next is suitable for passing to things that need a callback(err [, whatever]);
890
+ // it will result in this function being called again.
891
+ },
892
+ function(err) {
893
+ // if next is called with a value in its first parameter, it will appear
894
+ // in here as 'err', and execution will stop.
895
+ }
896
+ );
897
+ ```
898
+
899
+ ---------------------------------------
900
+
901
+ <a name="waterfall" />
902
+ ### waterfall(tasks, [callback])
903
+
904
+ Runs the `tasks` array of functions in series, each passing their results to the next in
905
+ the array. However, if any of the `tasks` pass an error to their own callback, the
906
+ next function is not executed, and the main `callback` is immediately called with
907
+ the error.
908
+
909
+ __Arguments__
910
+
911
+ * `tasks` - An array of functions to run, each function is passed a
912
+ `callback(err, result1, result2, ...)` it must call on completion. The first
913
+ argument is an error (which can be `null`) and any further arguments will be
914
+ passed as arguments in order to the next task.
915
+ * `callback(err, [results])` - An optional callback to run once all the functions
916
+ have completed. This will be passed the results of the last task's callback.
917
+
918
+
919
+
920
+ __Example__
921
+
922
+ ```js
923
+ async.waterfall([
924
+ function(callback) {
925
+ callback(null, 'one', 'two');
926
+ },
927
+ function(arg1, arg2, callback) {
928
+ // arg1 now equals 'one' and arg2 now equals 'two'
929
+ callback(null, 'three');
930
+ },
931
+ function(arg1, callback) {
932
+ // arg1 now equals 'three'
933
+ callback(null, 'done');
934
+ }
935
+ ], function (err, result) {
936
+ // result now equals 'done'
937
+ });
938
+ ```
939
+
940
+ ---------------------------------------
941
+ <a name="compose" />
942
+ ### compose(fn1, fn2...)
943
+
944
+ Creates a function which is a composition of the passed asynchronous
945
+ functions. Each function consumes the return value of the function that
946
+ follows. Composing functions `f()`, `g()`, and `h()` would produce the result of
947
+ `f(g(h()))`, only this version uses callbacks to obtain the return values.
948
+
949
+ Each function is executed with the `this` binding of the composed function.
950
+
951
+ __Arguments__
952
+
953
+ * `functions...` - the asynchronous functions to compose
954
+
955
+
956
+ __Example__
957
+
958
+ ```js
959
+ function add1(n, callback) {
960
+ setTimeout(function () {
961
+ callback(null, n + 1);
962
+ }, 10);
963
+ }
964
+
965
+ function mul3(n, callback) {
966
+ setTimeout(function () {
967
+ callback(null, n * 3);
968
+ }, 10);
969
+ }
970
+
971
+ var add1mul3 = async.compose(mul3, add1);
972
+
973
+ add1mul3(4, function (err, result) {
974
+ // result now equals 15
975
+ });
976
+ ```
977
+
978
+ ---------------------------------------
979
+ <a name="seq" />
980
+ ### seq(fn1, fn2...)
981
+
982
+ Version of the compose function that is more natural to read.
983
+ Each function consumes the return value of the previous function.
984
+ It is the equivalent of [`compose`](#compose) with the arguments reversed.
985
+
986
+ Each function is executed with the `this` binding of the composed function.
987
+
988
+ __Arguments__
989
+
990
+ * functions... - the asynchronous functions to compose
991
+
992
+
993
+ __Example__
994
+
995
+ ```js
996
+ // Requires lodash (or underscore), express3 and dresende's orm2.
997
+ // Part of an app, that fetches cats of the logged user.
998
+ // This example uses `seq` function to avoid overnesting and error
999
+ // handling clutter.
1000
+ app.get('/cats', function(request, response) {
1001
+ var User = request.models.User;
1002
+ async.seq(
1003
+ _.bind(User.get, User), // 'User.get' has signature (id, callback(err, data))
1004
+ function(user, fn) {
1005
+ user.getCats(fn); // 'getCats' has signature (callback(err, data))
1006
+ }
1007
+ )(req.session.user_id, function (err, cats) {
1008
+ if (err) {
1009
+ console.error(err);
1010
+ response.json({ status: 'error', message: err.message });
1011
+ } else {
1012
+ response.json({ status: 'ok', message: 'Cats found', data: cats });
1013
+ }
1014
+ });
1015
+ });
1016
+ ```
1017
+
1018
+ ---------------------------------------
1019
+ <a name="applyEach" />
1020
+ ### applyEach(fns, args..., callback)
1021
+
1022
+ Applies the provided arguments to each function in the array, calling
1023
+ `callback` after all functions have completed. If you only provide the first
1024
+ argument, then it will return a function which lets you pass in the
1025
+ arguments as if it were a single function call.
1026
+
1027
+ __Arguments__
1028
+
1029
+ * `fns` - the asynchronous functions to all call with the same arguments
1030
+ * `args...` - any number of separate arguments to pass to the function
1031
+ * `callback` - the final argument should be the callback, called when all
1032
+ functions have completed processing
1033
+
1034
+
1035
+ __Example__
1036
+
1037
+ ```js
1038
+ async.applyEach([enableSearch, updateSchema], 'bucket', callback);
1039
+
1040
+ // partial application example:
1041
+ async.each(
1042
+ buckets,
1043
+ async.applyEach([enableSearch, updateSchema]),
1044
+ callback
1045
+ );
1046
+ ```
1047
+
1048
+ ---------------------------------------
1049
+
1050
+ <a name="applyEachSeries" />
1051
+ ### applyEachSeries(arr, iterator, callback)
1052
+
1053
+ The same as [`applyEach`](#applyEach) only the functions are applied in series.
1054
+
1055
+ ---------------------------------------
1056
+
1057
+ <a name="queue" />
1058
+ ### queue(worker, concurrency)
1059
+
1060
+ Creates a `queue` object with the specified `concurrency`. Tasks added to the
1061
+ `queue` are processed in parallel (up to the `concurrency` limit). If all
1062
+ `worker`s are in progress, the task is queued until one becomes available.
1063
+ Once a `worker` completes a `task`, that `task`'s callback is called.
1064
+
1065
+ __Arguments__
1066
+
1067
+ * `worker(task, callback)` - An asynchronous function for processing a queued
1068
+ task, which must call its `callback(err)` argument when finished, with an
1069
+ optional `error` as an argument.
1070
+ * `concurrency` - An `integer` for determining how many `worker` functions should be
1071
+ run in parallel.
1072
+
1073
+ __Queue objects__
1074
+
1075
+ The `queue` object returned by this function has the following properties and
1076
+ methods:
1077
+
1078
+ * `length()` - a function returning the number of items waiting to be processed.
1079
+ * `started` - a function returning whether or not any items have been pushed and processed by the queue
1080
+ * `running()` - a function returning the number of items currently being processed.
1081
+ * `idle()` - a function returning false if there are items waiting or being processed, or true if not.
1082
+ * `concurrency` - an integer for determining how many `worker` functions should be
1083
+ run in parallel. This property can be changed after a `queue` is created to
1084
+ alter the concurrency on-the-fly.
1085
+ * `push(task, [callback])` - add a new task to the `queue`. Calls `callback` once
1086
+ the `worker` has finished processing the task. Instead of a single task, a `tasks` array
1087
+ can be submitted. The respective callback is used for every task in the list.
1088
+ * `unshift(task, [callback])` - add a new task to the front of the `queue`.
1089
+ * `saturated` - a callback that is called when the `queue` length hits the `concurrency` limit,
1090
+ and further tasks will be queued.
1091
+ * `empty` - a callback that is called when the last item from the `queue` is given to a `worker`.
1092
+ * `drain` - a callback that is called when the last item from the `queue` has returned from the `worker`.
1093
+ * `paused` - a boolean for determining whether the queue is in a paused state
1094
+ * `pause()` - a function that pauses the processing of tasks until `resume()` is called.
1095
+ * `resume()` - a function that resumes the processing of queued tasks when the queue is paused.
1096
+ * `kill()` - a function that removes the `drain` callback and empties remaining tasks from the queue forcing it to go idle.
1097
+
1098
+ __Example__
1099
+
1100
+ ```js
1101
+ // create a queue object with concurrency 2
1102
+
1103
+ var q = async.queue(function (task, callback) {
1104
+ console.log('hello ' + task.name);
1105
+ callback();
1106
+ }, 2);
1107
+
1108
+
1109
+ // assign a callback
1110
+ q.drain = function() {
1111
+ console.log('all items have been processed');
1112
+ }
1113
+
1114
+ // add some items to the queue
1115
+
1116
+ q.push({name: 'foo'}, function (err) {
1117
+ console.log('finished processing foo');
1118
+ });
1119
+ q.push({name: 'bar'}, function (err) {
1120
+ console.log('finished processing bar');
1121
+ });
1122
+
1123
+ // add some items to the queue (batch-wise)
1124
+
1125
+ q.push([{name: 'baz'},{name: 'bay'},{name: 'bax'}], function (err) {
1126
+ console.log('finished processing item');
1127
+ });
1128
+
1129
+ // add some items to the front of the queue
1130
+
1131
+ q.unshift({name: 'bar'}, function (err) {
1132
+ console.log('finished processing bar');
1133
+ });
1134
+ ```
1135
+
1136
+
1137
+ ---------------------------------------
1138
+
1139
+ <a name="priorityQueue" />
1140
+ ### priorityQueue(worker, concurrency)
1141
+
1142
+ The same as [`queue`](#queue) only tasks are assigned a priority and completed in ascending priority order. There are two differences between `queue` and `priorityQueue` objects:
1143
+
1144
+ * `push(task, priority, [callback])` - `priority` should be a number. If an array of
1145
+ `tasks` is given, all tasks will be assigned the same priority.
1146
+ * The `unshift` method was removed.
1147
+
1148
+ ---------------------------------------
1149
+
1150
+ <a name="cargo" />
1151
+ ### cargo(worker, [payload])
1152
+
1153
+ Creates a `cargo` object with the specified payload. Tasks added to the
1154
+ cargo will be processed altogether (up to the `payload` limit). If the
1155
+ `worker` is in progress, the task is queued until it becomes available. Once
1156
+ the `worker` has completed some tasks, each callback of those tasks is called.
1157
+ Check out [this animation](https://camo.githubusercontent.com/6bbd36f4cf5b35a0f11a96dcd2e97711ffc2fb37/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f313637363837312f36383130382f62626330636662302d356632392d313165322d393734662d3333393763363464633835382e676966) for how `cargo` and `queue` work.
1158
+
1159
+ While [queue](#queue) passes only one task to one of a group of workers
1160
+ at a time, cargo passes an array of tasks to a single worker, repeating
1161
+ when the worker is finished.
1162
+
1163
+ __Arguments__
1164
+
1165
+ * `worker(tasks, callback)` - An asynchronous function for processing an array of
1166
+ queued tasks, which must call its `callback(err)` argument when finished, with
1167
+ an optional `err` argument.
1168
+ * `payload` - An optional `integer` for determining how many tasks should be
1169
+ processed per round; if omitted, the default is unlimited.
1170
+
1171
+ __Cargo objects__
1172
+
1173
+ The `cargo` object returned by this function has the following properties and
1174
+ methods:
1175
+
1176
+ * `length()` - A function returning the number of items waiting to be processed.
1177
+ * `payload` - An `integer` for determining how many tasks should be
1178
+ process per round. This property can be changed after a `cargo` is created to
1179
+ alter the payload on-the-fly.
1180
+ * `push(task, [callback])` - Adds `task` to the `queue`. The callback is called
1181
+ once the `worker` has finished processing the task. Instead of a single task, an array of `tasks`
1182
+ can be submitted. The respective callback is used for every task in the list.
1183
+ * `saturated` - A callback that is called when the `queue.length()` hits the concurrency and further tasks will be queued.
1184
+ * `empty` - A callback that is called when the last item from the `queue` is given to a `worker`.
1185
+ * `drain` - A callback that is called when the last item from the `queue` has returned from the `worker`.
1186
+
1187
+ __Example__
1188
+
1189
+ ```js
1190
+ // create a cargo object with payload 2
1191
+
1192
+ var cargo = async.cargo(function (tasks, callback) {
1193
+ for(var i=0; i<tasks.length; i++){
1194
+ console.log('hello ' + tasks[i].name);
1195
+ }
1196
+ callback();
1197
+ }, 2);
1198
+
1199
+
1200
+ // add some items
1201
+
1202
+ cargo.push({name: 'foo'}, function (err) {
1203
+ console.log('finished processing foo');
1204
+ });
1205
+ cargo.push({name: 'bar'}, function (err) {
1206
+ console.log('finished processing bar');
1207
+ });
1208
+ cargo.push({name: 'baz'}, function (err) {
1209
+ console.log('finished processing baz');
1210
+ });
1211
+ ```
1212
+
1213
+ ---------------------------------------
1214
+
1215
+ <a name="auto" />
1216
+ ### auto(tasks, [callback])
1217
+
1218
+ Determines the best order for running the functions in `tasks`, based on their
1219
+ requirements. Each function can optionally depend on other functions being completed
1220
+ first, and each function is run as soon as its requirements are satisfied.
1221
+
1222
+ If any of the functions pass an error to their callback, it will not
1223
+ complete (so any other functions depending on it will not run), and the main
1224
+ `callback` is immediately called with the error. Functions also receive an
1225
+ object containing the results of functions which have completed so far.
1226
+
1227
+ Note, all functions are called with a `results` object as a second argument,
1228
+ so it is unsafe to pass functions in the `tasks` object which cannot handle the
1229
+ extra argument.
1230
+
1231
+ For example, this snippet of code:
1232
+
1233
+ ```js
1234
+ async.auto({
1235
+ readData: async.apply(fs.readFile, 'data.txt', 'utf-8')
1236
+ }, callback);
1237
+ ```
1238
+
1239
+ will have the effect of calling `readFile` with the results object as the last
1240
+ argument, which will fail:
1241
+
1242
+ ```js
1243
+ fs.readFile('data.txt', 'utf-8', cb, {});
1244
+ ```
1245
+
1246
+ Instead, wrap the call to `readFile` in a function which does not forward the
1247
+ `results` object:
1248
+
1249
+ ```js
1250
+ async.auto({
1251
+ readData: function(cb, results){
1252
+ fs.readFile('data.txt', 'utf-8', cb);
1253
+ }
1254
+ }, callback);
1255
+ ```
1256
+
1257
+ __Arguments__
1258
+
1259
+ * `tasks` - An object. Each of its properties is either a function or an array of
1260
+ requirements, with the function itself the last item in the array. The object's key
1261
+ of a property serves as the name of the task defined by that property,
1262
+ i.e. can be used when specifying requirements for other tasks.
1263
+ The function receives two arguments: (1) a `callback(err, result)` which must be
1264
+ called when finished, passing an `error` (which can be `null`) and the result of
1265
+ the function's execution, and (2) a `results` object, containing the results of
1266
+ the previously executed functions.
1267
+ * `callback(err, results)` - An optional callback which is called when all the
1268
+ tasks have been completed. It receives the `err` argument if any `tasks`
1269
+ pass an error to their callback. Results are always returned; however, if
1270
+ an error occurs, no further `tasks` will be performed, and the results
1271
+ object will only contain partial results.
1272
+
1273
+
1274
+ __Example__
1275
+
1276
+ ```js
1277
+ async.auto({
1278
+ get_data: function(callback){
1279
+ console.log('in get_data');
1280
+ // async code to get some data
1281
+ callback(null, 'data', 'converted to array');
1282
+ },
1283
+ make_folder: function(callback){
1284
+ console.log('in make_folder');
1285
+ // async code to create a directory to store a file in
1286
+ // this is run at the same time as getting the data
1287
+ callback(null, 'folder');
1288
+ },
1289
+ write_file: ['get_data', 'make_folder', function(callback, results){
1290
+ console.log('in write_file', JSON.stringify(results));
1291
+ // once there is some data and the directory exists,
1292
+ // write the data to a file in the directory
1293
+ callback(null, 'filename');
1294
+ }],
1295
+ email_link: ['write_file', function(callback, results){
1296
+ console.log('in email_link', JSON.stringify(results));
1297
+ // once the file is written let's email a link to it...
1298
+ // results.write_file contains the filename returned by write_file.
1299
+ callback(null, {'file':results.write_file, 'email':'user@example.com'});
1300
+ }]
1301
+ }, function(err, results) {
1302
+ console.log('err = ', err);
1303
+ console.log('results = ', results);
1304
+ });
1305
+ ```
1306
+
1307
+ This is a fairly trivial example, but to do this using the basic parallel and
1308
+ series functions would look like this:
1309
+
1310
+ ```js
1311
+ async.parallel([
1312
+ function(callback){
1313
+ console.log('in get_data');
1314
+ // async code to get some data
1315
+ callback(null, 'data', 'converted to array');
1316
+ },
1317
+ function(callback){
1318
+ console.log('in make_folder');
1319
+ // async code to create a directory to store a file in
1320
+ // this is run at the same time as getting the data
1321
+ callback(null, 'folder');
1322
+ }
1323
+ ],
1324
+ function(err, results){
1325
+ async.series([
1326
+ function(callback){
1327
+ console.log('in write_file', JSON.stringify(results));
1328
+ // once there is some data and the directory exists,
1329
+ // write the data to a file in the directory
1330
+ results.push('filename');
1331
+ callback(null);
1332
+ },
1333
+ function(callback){
1334
+ console.log('in email_link', JSON.stringify(results));
1335
+ // once the file is written let's email a link to it...
1336
+ callback(null, {'file':results.pop(), 'email':'user@example.com'});
1337
+ }
1338
+ ]);
1339
+ });
1340
+ ```
1341
+
1342
+ For a complicated series of `async` tasks, using the [`auto`](#auto) function makes adding
1343
+ new tasks much easier (and the code more readable).
1344
+
1345
+
1346
+ ---------------------------------------
1347
+
1348
+ <a name="retry" />
1349
+ ### retry([times = 5], task, [callback])
1350
+
1351
+ Attempts to get a successful response from `task` no more than `times` times before
1352
+ returning an error. If the task is successful, the `callback` will be passed the result
1353
+ of the successful task. If all attempts fail, the callback will be passed the error and
1354
+ result (if any) of the final attempt.
1355
+
1356
+ __Arguments__
1357
+
1358
+ * `times` - An integer indicating how many times to attempt the `task` before giving up. Defaults to 5.
1359
+ * `task(callback, results)` - A function which receives two arguments: (1) a `callback(err, result)`
1360
+ which must be called when finished, passing `err` (which can be `null`) and the `result` of
1361
+ the function's execution, and (2) a `results` object, containing the results of
1362
+ the previously executed functions (if nested inside another control flow).
1363
+ * `callback(err, results)` - An optional callback which is called when the
1364
+ task has succeeded, or after the final failed attempt. It receives the `err` and `result` arguments of the last attempt at completing the `task`.
1365
+
1366
+ The [`retry`](#retry) function can be used as a stand-alone control flow by passing a
1367
+ callback, as shown below:
1368
+
1369
+ ```js
1370
+ async.retry(3, apiMethod, function(err, result) {
1371
+ // do something with the result
1372
+ });
1373
+ ```
1374
+
1375
+ It can also be embeded within other control flow functions to retry individual methods
1376
+ that are not as reliable, like this:
1377
+
1378
+ ```js
1379
+ async.auto({
1380
+ users: api.getUsers.bind(api),
1381
+ payments: async.retry(3, api.getPayments.bind(api))
1382
+ }, function(err, results) {
1383
+ // do something with the results
1384
+ });
1385
+ ```
1386
+
1387
+
1388
+ ---------------------------------------
1389
+
1390
+ <a name="iterator" />
1391
+ ### iterator(tasks)
1392
+
1393
+ Creates an iterator function which calls the next function in the `tasks` array,
1394
+ returning a continuation to call the next one after that. It's also possible to
1395
+ “peek” at the next iterator with `iterator.next()`.
1396
+
1397
+ This function is used internally by the `async` module, but can be useful when
1398
+ you want to manually control the flow of functions in series.
1399
+
1400
+ __Arguments__
1401
+
1402
+ * `tasks` - An array of functions to run.
1403
+
1404
+ __Example__
1405
+
1406
+ ```js
1407
+ var iterator = async.iterator([
1408
+ function(){ sys.p('one'); },
1409
+ function(){ sys.p('two'); },
1410
+ function(){ sys.p('three'); }
1411
+ ]);
1412
+
1413
+ node> var iterator2 = iterator();
1414
+ 'one'
1415
+ node> var iterator3 = iterator2();
1416
+ 'two'
1417
+ node> iterator3();
1418
+ 'three'
1419
+ node> var nextfn = iterator2.next();
1420
+ node> nextfn();
1421
+ 'three'
1422
+ ```
1423
+
1424
+ ---------------------------------------
1425
+
1426
+ <a name="apply" />
1427
+ ### apply(function, arguments..)
1428
+
1429
+ Creates a continuation function with some arguments already applied.
1430
+
1431
+ Useful as a shorthand when combined with other control flow functions. Any arguments
1432
+ passed to the returned function are added to the arguments originally passed
1433
+ to apply.
1434
+
1435
+ __Arguments__
1436
+
1437
+ * `function` - The function you want to eventually apply all arguments to.
1438
+ * `arguments...` - Any number of arguments to automatically apply when the
1439
+ continuation is called.
1440
+
1441
+ __Example__
1442
+
1443
+ ```js
1444
+ // using apply
1445
+
1446
+ async.parallel([
1447
+ async.apply(fs.writeFile, 'testfile1', 'test1'),
1448
+ async.apply(fs.writeFile, 'testfile2', 'test2'),
1449
+ ]);
1450
+
1451
+
1452
+ // the same process without using apply
1453
+
1454
+ async.parallel([
1455
+ function(callback){
1456
+ fs.writeFile('testfile1', 'test1', callback);
1457
+ },
1458
+ function(callback){
1459
+ fs.writeFile('testfile2', 'test2', callback);
1460
+ }
1461
+ ]);
1462
+ ```
1463
+
1464
+ It's possible to pass any number of additional arguments when calling the
1465
+ continuation:
1466
+
1467
+ ```js
1468
+ node> var fn = async.apply(sys.puts, 'one');
1469
+ node> fn('two', 'three');
1470
+ one
1471
+ two
1472
+ three
1473
+ ```
1474
+
1475
+ ---------------------------------------
1476
+
1477
+ <a name="nextTick" />
1478
+ ### nextTick(callback), setImmediate(callback)
1479
+
1480
+ Calls `callback` on a later loop around the event loop. In Node.js this just
1481
+ calls `process.nextTick`; in the browser it falls back to `setImmediate(callback)`
1482
+ if available, otherwise `setTimeout(callback, 0)`, which means other higher priority
1483
+ events may precede the execution of `callback`.
1484
+
1485
+ This is used internally for browser-compatibility purposes.
1486
+
1487
+ __Arguments__
1488
+
1489
+ * `callback` - The function to call on a later loop around the event loop.
1490
+
1491
+ __Example__
1492
+
1493
+ ```js
1494
+ var call_order = [];
1495
+ async.nextTick(function(){
1496
+ call_order.push('two');
1497
+ // call_order now equals ['one','two']
1498
+ });
1499
+ call_order.push('one')
1500
+ ```
1501
+
1502
+ <a name="times" />
1503
+ ### times(n, callback)
1504
+
1505
+ Calls the `callback` function `n` times, and accumulates results in the same manner
1506
+ you would use with [`map`](#map).
1507
+
1508
+ __Arguments__
1509
+
1510
+ * `n` - The number of times to run the function.
1511
+ * `callback` - The function to call `n` times.
1512
+
1513
+ __Example__
1514
+
1515
+ ```js
1516
+ // Pretend this is some complicated async factory
1517
+ var createUser = function(id, callback) {
1518
+ callback(null, {
1519
+ id: 'user' + id
1520
+ })
1521
+ }
1522
+ // generate 5 users
1523
+ async.times(5, function(n, next){
1524
+ createUser(n, function(err, user) {
1525
+ next(err, user)
1526
+ })
1527
+ }, function(err, users) {
1528
+ // we should now have 5 users
1529
+ });
1530
+ ```
1531
+
1532
+ <a name="timesSeries" />
1533
+ ### timesSeries(n, callback)
1534
+
1535
+ The same as [`times`](#times), only the iterator is applied to each item in `arr` in
1536
+ series. The next `iterator` is only called once the current one has completed.
1537
+ The results array will be in the same order as the original.
1538
+
1539
+
1540
+ ## Utils
1541
+
1542
+ <a name="memoize" />
1543
+ ### memoize(fn, [hasher])
1544
+
1545
+ Caches the results of an `async` function. When creating a hash to store function
1546
+ results against, the callback is omitted from the hash and an optional hash
1547
+ function can be used.
1548
+
1549
+ The cache of results is exposed as the `memo` property of the function returned
1550
+ by `memoize`.
1551
+
1552
+ __Arguments__
1553
+
1554
+ * `fn` - The function to proxy and cache results from.
1555
+ * `hasher` - Tn optional function for generating a custom hash for storing
1556
+ results. It has all the arguments applied to it apart from the callback, and
1557
+ must be synchronous.
1558
+
1559
+ __Example__
1560
+
1561
+ ```js
1562
+ var slow_fn = function (name, callback) {
1563
+ // do something
1564
+ callback(null, result);
1565
+ };
1566
+ var fn = async.memoize(slow_fn);
1567
+
1568
+ // fn can now be used as if it were slow_fn
1569
+ fn('some name', function () {
1570
+ // callback
1571
+ });
1572
+ ```
1573
+
1574
+ <a name="unmemoize" />
1575
+ ### unmemoize(fn)
1576
+
1577
+ Undoes a [`memoize`](#memoize)d function, reverting it to the original, unmemoized
1578
+ form. Handy for testing.
1579
+
1580
+ __Arguments__
1581
+
1582
+ * `fn` - the memoized function
1583
+
1584
+ <a name="log" />
1585
+ ### log(function, arguments)
1586
+
1587
+ Logs the result of an `async` function to the `console`. Only works in Node.js or
1588
+ in browsers that support `console.log` and `console.error` (such as FF and Chrome).
1589
+ If multiple arguments are returned from the async function, `console.log` is
1590
+ called on each argument in order.
1591
+
1592
+ __Arguments__
1593
+
1594
+ * `function` - The function you want to eventually apply all arguments to.
1595
+ * `arguments...` - Any number of arguments to apply to the function.
1596
+
1597
+ __Example__
1598
+
1599
+ ```js
1600
+ var hello = function(name, callback){
1601
+ setTimeout(function(){
1602
+ callback(null, 'hello ' + name);
1603
+ }, 1000);
1604
+ };
1605
+ ```
1606
+ ```js
1607
+ node> async.log(hello, 'world');
1608
+ 'hello world'
1609
+ ```
1610
+
1611
+ ---------------------------------------
1612
+
1613
+ <a name="dir" />
1614
+ ### dir(function, arguments)
1615
+
1616
+ Logs the result of an `async` function to the `console` using `console.dir` to
1617
+ display the properties of the resulting object. Only works in Node.js or
1618
+ in browsers that support `console.dir` and `console.error` (such as FF and Chrome).
1619
+ If multiple arguments are returned from the async function, `console.dir` is
1620
+ called on each argument in order.
1621
+
1622
+ __Arguments__
1623
+
1624
+ * `function` - The function you want to eventually apply all arguments to.
1625
+ * `arguments...` - Any number of arguments to apply to the function.
1626
+
1627
+ __Example__
1628
+
1629
+ ```js
1630
+ var hello = function(name, callback){
1631
+ setTimeout(function(){
1632
+ callback(null, {hello: name});
1633
+ }, 1000);
1634
+ };
1635
+ ```
1636
+ ```js
1637
+ node> async.dir(hello, 'world');
1638
+ {hello: 'world'}
1639
+ ```
1640
+
1641
+ ---------------------------------------
1642
+
1643
+ <a name="noConflict" />
1644
+ ### noConflict()
1645
+
1646
+ Changes the value of `async` back to its original value, returning a reference to the
1647
+ `async` object.