ai 1.1.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (340) hide show
  1. package/LICENSE +10 -24
  2. package/dist/ai-stream.d.ts +18 -0
  3. package/dist/ai-stream.js +132 -0
  4. package/dist/ai-stream.mjs +13 -0
  5. package/dist/anthropic-stream.d.ts +5 -0
  6. package/dist/anthropic-stream.js +133 -0
  7. package/dist/anthropic-stream.mjs +8 -0
  8. package/dist/chunk-265FSSO4.mjs +91 -0
  9. package/dist/chunk-2L3ZO4UM.mjs +45 -0
  10. package/dist/chunk-GT4HKF2X.mjs +33 -0
  11. package/dist/chunk-JGDC3BXD.mjs +22 -0
  12. package/dist/chunk-NK2CVBLI.mjs +38 -0
  13. package/dist/chunk-PEYAHBDF.mjs +43 -0
  14. package/dist/chunk-TJMME6CL.mjs +24 -0
  15. package/dist/huggingface-stream.d.ts +5 -0
  16. package/dist/huggingface-stream.js +121 -0
  17. package/dist/huggingface-stream.mjs +8 -0
  18. package/dist/index.d.ts +131 -0
  19. package/dist/index.js +278 -0
  20. package/dist/index.mjs +35 -0
  21. package/dist/index.test.d.ts +2 -0
  22. package/dist/index.test.js +12 -0
  23. package/dist/index.test.mjs +10 -0
  24. package/dist/langchain-stream.d.ts +12 -0
  25. package/dist/langchain-stream.js +102 -0
  26. package/dist/langchain-stream.mjs +8 -0
  27. package/dist/openai-stream.d.ts +5 -0
  28. package/dist/openai-stream.js +144 -0
  29. package/dist/openai-stream.mjs +8 -0
  30. package/dist/streaming-text-response.d.ts +17 -0
  31. package/dist/streaming-text-response.js +75 -0
  32. package/dist/streaming-text-response.mjs +9 -0
  33. package/package.json +78 -29
  34. package/react/dist/chunk-5PP6W52J.mjs +202 -0
  35. package/react/dist/chunk-6EH3SWMP.mjs +55 -0
  36. package/react/dist/chunk-PW6HSU2N.mjs +154 -0
  37. package/react/dist/index.d.ts +3 -0
  38. package/react/dist/index.js +424 -0
  39. package/react/dist/index.mjs +12 -0
  40. package/react/dist/types-f862f74a.d.ts +123 -0
  41. package/react/dist/use-chat.d.ts +42 -0
  42. package/react/dist/use-chat.js +276 -0
  43. package/react/dist/use-chat.mjs +8 -0
  44. package/react/dist/use-completion.d.ts +47 -0
  45. package/react/dist/use-completion.js +229 -0
  46. package/react/dist/use-completion.mjs +8 -0
  47. package/svelte/dist/chunk-6USBQIV6.mjs +177 -0
  48. package/svelte/dist/chunk-BQ64GHZ3.mjs +136 -0
  49. package/svelte/dist/chunk-CENOSGDG.mjs +493 -0
  50. package/svelte/dist/index.d.ts +4 -0
  51. package/svelte/dist/index.js +808 -0
  52. package/svelte/dist/index.mjs +11 -0
  53. package/svelte/dist/types-f862f74a.d.ts +123 -0
  54. package/svelte/dist/use-chat.d.ts +39 -0
  55. package/svelte/dist/use-chat.js +680 -0
  56. package/svelte/dist/use-chat.mjs +7 -0
  57. package/svelte/dist/use-completion.d.ts +38 -0
  58. package/svelte/dist/use-completion.js +640 -0
  59. package/svelte/dist/use-completion.mjs +7 -0
  60. package/.npmignore +0 -15
  61. package/.travis.yml +0 -4
  62. package/README.md +0 -21
  63. package/bin/ai.js +0 -22
  64. package/index.js +0 -37
  65. package/node_modules/request/.npmignore +0 -2
  66. package/node_modules/request/.travis.yml +0 -12
  67. package/node_modules/request/CHANGELOG.md +0 -954
  68. package/node_modules/request/LICENSE +0 -55
  69. package/node_modules/request/README.md +0 -421
  70. package/node_modules/request/index.js +0 -166
  71. package/node_modules/request/lib/cookies.js +0 -40
  72. package/node_modules/request/lib/copy.js +0 -8
  73. package/node_modules/request/lib/debug.js +0 -7
  74. package/node_modules/request/lib/getSafe.js +0 -34
  75. package/node_modules/request/lib/optional.js +0 -5
  76. package/node_modules/request/node_modules/aws-sign2/LICENSE +0 -55
  77. package/node_modules/request/node_modules/aws-sign2/README.md +0 -4
  78. package/node_modules/request/node_modules/aws-sign2/index.js +0 -202
  79. package/node_modules/request/node_modules/aws-sign2/package.json +0 -47
  80. package/node_modules/request/node_modules/forever-agent/LICENSE +0 -55
  81. package/node_modules/request/node_modules/forever-agent/README.md +0 -4
  82. package/node_modules/request/node_modules/forever-agent/index.js +0 -119
  83. package/node_modules/request/node_modules/forever-agent/package.json +0 -46
  84. package/node_modules/request/node_modules/form-data/License +0 -19
  85. package/node_modules/request/node_modules/form-data/Readme.md +0 -175
  86. package/node_modules/request/node_modules/form-data/lib/form_data.js +0 -351
  87. package/node_modules/request/node_modules/form-data/node_modules/async/.travis.yml +0 -3
  88. package/node_modules/request/node_modules/form-data/node_modules/async/LICENSE +0 -19
  89. package/node_modules/request/node_modules/form-data/node_modules/async/README.md +0 -1646
  90. package/node_modules/request/node_modules/form-data/node_modules/async/component.json +0 -11
  91. package/node_modules/request/node_modules/form-data/node_modules/async/lib/async.js +0 -1123
  92. package/node_modules/request/node_modules/form-data/node_modules/async/package.json +0 -60
  93. package/node_modules/request/node_modules/form-data/node_modules/combined-stream/License +0 -19
  94. package/node_modules/request/node_modules/form-data/node_modules/combined-stream/Readme.md +0 -132
  95. package/node_modules/request/node_modules/form-data/node_modules/combined-stream/lib/combined_stream.js +0 -186
  96. package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/.npmignore +0 -2
  97. package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/License +0 -19
  98. package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/Makefile +0 -7
  99. package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/Readme.md +0 -154
  100. package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/lib/delayed_stream.js +0 -99
  101. package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/package.json +0 -42
  102. package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/common.js +0 -6
  103. package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-http-upload.js +0 -38
  104. package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-stream-auto-pause.js +0 -21
  105. package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-stream-pause.js +0 -14
  106. package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-stream.js +0 -48
  107. package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-handle-source-errors.js +0 -15
  108. package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-max-data-size.js +0 -18
  109. package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-pipe-resumes.js +0 -13
  110. package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-proxy-readable.js +0 -13
  111. package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/run.js +0 -7
  112. package/node_modules/request/node_modules/form-data/node_modules/combined-stream/package.json +0 -61
  113. package/node_modules/request/node_modules/form-data/node_modules/mime/LICENSE +0 -19
  114. package/node_modules/request/node_modules/form-data/node_modules/mime/README.md +0 -66
  115. package/node_modules/request/node_modules/form-data/node_modules/mime/mime.js +0 -114
  116. package/node_modules/request/node_modules/form-data/node_modules/mime/package.json +0 -59
  117. package/node_modules/request/node_modules/form-data/node_modules/mime/test.js +0 -84
  118. package/node_modules/request/node_modules/form-data/node_modules/mime/types/mime.types +0 -1588
  119. package/node_modules/request/node_modules/form-data/node_modules/mime/types/node.types +0 -77
  120. package/node_modules/request/node_modules/form-data/package.json +0 -80
  121. package/node_modules/request/node_modules/hawk/.npmignore +0 -18
  122. package/node_modules/request/node_modules/hawk/.travis.yml +0 -5
  123. package/node_modules/request/node_modules/hawk/LICENSE +0 -24
  124. package/node_modules/request/node_modules/hawk/Makefile +0 -10
  125. package/node_modules/request/node_modules/hawk/README.md +0 -625
  126. package/node_modules/request/node_modules/hawk/example/usage.js +0 -78
  127. package/node_modules/request/node_modules/hawk/images/hawk.png +0 -0
  128. package/node_modules/request/node_modules/hawk/images/logo.png +0 -0
  129. package/node_modules/request/node_modules/hawk/index.js +0 -1
  130. package/node_modules/request/node_modules/hawk/lib/browser.js +0 -507
  131. package/node_modules/request/node_modules/hawk/lib/client.js +0 -371
  132. package/node_modules/request/node_modules/hawk/lib/crypto.js +0 -118
  133. package/node_modules/request/node_modules/hawk/lib/index.js +0 -15
  134. package/node_modules/request/node_modules/hawk/lib/server.js +0 -523
  135. package/node_modules/request/node_modules/hawk/lib/utils.js +0 -183
  136. package/node_modules/request/node_modules/hawk/node_modules/boom/.npmignore +0 -18
  137. package/node_modules/request/node_modules/hawk/node_modules/boom/.travis.yml +0 -5
  138. package/node_modules/request/node_modules/hawk/node_modules/boom/LICENSE +0 -24
  139. package/node_modules/request/node_modules/hawk/node_modules/boom/Makefile +0 -11
  140. package/node_modules/request/node_modules/hawk/node_modules/boom/README.md +0 -6
  141. package/node_modules/request/node_modules/hawk/node_modules/boom/images/boom.png +0 -0
  142. package/node_modules/request/node_modules/hawk/node_modules/boom/index.js +0 -1
  143. package/node_modules/request/node_modules/hawk/node_modules/boom/lib/index.js +0 -207
  144. package/node_modules/request/node_modules/hawk/node_modules/boom/package.json +0 -64
  145. package/node_modules/request/node_modules/hawk/node_modules/boom/test/index.js +0 -245
  146. package/node_modules/request/node_modules/hawk/node_modules/cryptiles/.npmignore +0 -18
  147. package/node_modules/request/node_modules/hawk/node_modules/cryptiles/.travis.yml +0 -5
  148. package/node_modules/request/node_modules/hawk/node_modules/cryptiles/LICENSE +0 -24
  149. package/node_modules/request/node_modules/hawk/node_modules/cryptiles/Makefile +0 -11
  150. package/node_modules/request/node_modules/hawk/node_modules/cryptiles/README.md +0 -6
  151. package/node_modules/request/node_modules/hawk/node_modules/cryptiles/index.js +0 -1
  152. package/node_modules/request/node_modules/hawk/node_modules/cryptiles/lib/index.js +0 -68
  153. package/node_modules/request/node_modules/hawk/node_modules/cryptiles/package.json +0 -65
  154. package/node_modules/request/node_modules/hawk/node_modules/cryptiles/test/index.js +0 -101
  155. package/node_modules/request/node_modules/hawk/node_modules/hoek/.npmignore +0 -18
  156. package/node_modules/request/node_modules/hawk/node_modules/hoek/.travis.yml +0 -5
  157. package/node_modules/request/node_modules/hawk/node_modules/hoek/LICENSE +0 -33
  158. package/node_modules/request/node_modules/hawk/node_modules/hoek/Makefile +0 -10
  159. package/node_modules/request/node_modules/hawk/node_modules/hoek/README.md +0 -436
  160. package/node_modules/request/node_modules/hawk/node_modules/hoek/images/hoek.png +0 -0
  161. package/node_modules/request/node_modules/hawk/node_modules/hoek/index.js +0 -1
  162. package/node_modules/request/node_modules/hawk/node_modules/hoek/lib/escape.js +0 -132
  163. package/node_modules/request/node_modules/hawk/node_modules/hoek/lib/index.js +0 -585
  164. package/node_modules/request/node_modules/hawk/node_modules/hoek/package.json +0 -70
  165. package/node_modules/request/node_modules/hawk/node_modules/hoek/test/escaper.js +0 -86
  166. package/node_modules/request/node_modules/hawk/node_modules/hoek/test/index.js +0 -1078
  167. package/node_modules/request/node_modules/hawk/node_modules/hoek/test/modules/test1.js +0 -1
  168. package/node_modules/request/node_modules/hawk/node_modules/hoek/test/modules/test2.js +0 -1
  169. package/node_modules/request/node_modules/hawk/node_modules/hoek/test/modules/test3.js +0 -1
  170. package/node_modules/request/node_modules/hawk/node_modules/sntp/.npmignore +0 -18
  171. package/node_modules/request/node_modules/hawk/node_modules/sntp/.travis.yml +0 -5
  172. package/node_modules/request/node_modules/hawk/node_modules/sntp/LICENSE +0 -24
  173. package/node_modules/request/node_modules/hawk/node_modules/sntp/Makefile +0 -11
  174. package/node_modules/request/node_modules/hawk/node_modules/sntp/README.md +0 -68
  175. package/node_modules/request/node_modules/hawk/node_modules/sntp/examples/offset.js +0 -16
  176. package/node_modules/request/node_modules/hawk/node_modules/sntp/examples/time.js +0 -25
  177. package/node_modules/request/node_modules/hawk/node_modules/sntp/index.js +0 -1
  178. package/node_modules/request/node_modules/hawk/node_modules/sntp/lib/index.js +0 -409
  179. package/node_modules/request/node_modules/hawk/node_modules/sntp/package.json +0 -65
  180. package/node_modules/request/node_modules/hawk/node_modules/sntp/test/index.js +0 -359
  181. package/node_modules/request/node_modules/hawk/package.json +0 -70
  182. package/node_modules/request/node_modules/hawk/test/browser.js +0 -817
  183. package/node_modules/request/node_modules/hawk/test/client.js +0 -206
  184. package/node_modules/request/node_modules/hawk/test/crypto.js +0 -86
  185. package/node_modules/request/node_modules/hawk/test/index.js +0 -316
  186. package/node_modules/request/node_modules/hawk/test/message.js +0 -246
  187. package/node_modules/request/node_modules/hawk/test/readme.js +0 -98
  188. package/node_modules/request/node_modules/hawk/test/server.js +0 -686
  189. package/node_modules/request/node_modules/hawk/test/uri.js +0 -456
  190. package/node_modules/request/node_modules/hawk/test/utils.js +0 -120
  191. package/node_modules/request/node_modules/http-signature/.dir-locals.el +0 -6
  192. package/node_modules/request/node_modules/http-signature/.npmignore +0 -7
  193. package/node_modules/request/node_modules/http-signature/LICENSE +0 -18
  194. package/node_modules/request/node_modules/http-signature/README.md +0 -75
  195. package/node_modules/request/node_modules/http-signature/http_signing.md +0 -296
  196. package/node_modules/request/node_modules/http-signature/lib/index.js +0 -25
  197. package/node_modules/request/node_modules/http-signature/lib/parser.js +0 -304
  198. package/node_modules/request/node_modules/http-signature/lib/signer.js +0 -179
  199. package/node_modules/request/node_modules/http-signature/lib/util.js +0 -249
  200. package/node_modules/request/node_modules/http-signature/lib/verify.js +0 -42
  201. package/node_modules/request/node_modules/http-signature/node_modules/asn1/.npmignore +0 -2
  202. package/node_modules/request/node_modules/http-signature/node_modules/asn1/LICENSE +0 -19
  203. package/node_modules/request/node_modules/http-signature/node_modules/asn1/README.md +0 -50
  204. package/node_modules/request/node_modules/http-signature/node_modules/asn1/lib/ber/errors.js +0 -13
  205. package/node_modules/request/node_modules/http-signature/node_modules/asn1/lib/ber/index.js +0 -27
  206. package/node_modules/request/node_modules/http-signature/node_modules/asn1/lib/ber/reader.js +0 -267
  207. package/node_modules/request/node_modules/http-signature/node_modules/asn1/lib/ber/types.js +0 -36
  208. package/node_modules/request/node_modules/http-signature/node_modules/asn1/lib/ber/writer.js +0 -317
  209. package/node_modules/request/node_modules/http-signature/node_modules/asn1/lib/index.js +0 -20
  210. package/node_modules/request/node_modules/http-signature/node_modules/asn1/package.json +0 -63
  211. package/node_modules/request/node_modules/http-signature/node_modules/asn1/tst/ber/reader.test.js +0 -172
  212. package/node_modules/request/node_modules/http-signature/node_modules/asn1/tst/ber/writer.test.js +0 -296
  213. package/node_modules/request/node_modules/http-signature/node_modules/assert-plus/README.md +0 -126
  214. package/node_modules/request/node_modules/http-signature/node_modules/assert-plus/assert.js +0 -196
  215. package/node_modules/request/node_modules/http-signature/node_modules/assert-plus/package.json +0 -38
  216. package/node_modules/request/node_modules/http-signature/node_modules/ctype/CHANGELOG +0 -71
  217. package/node_modules/request/node_modules/http-signature/node_modules/ctype/LICENSE +0 -24
  218. package/node_modules/request/node_modules/http-signature/node_modules/ctype/README +0 -82
  219. package/node_modules/request/node_modules/http-signature/node_modules/ctype/README.old +0 -298
  220. package/node_modules/request/node_modules/http-signature/node_modules/ctype/ctf.js +0 -245
  221. package/node_modules/request/node_modules/http-signature/node_modules/ctype/ctio.js +0 -1485
  222. package/node_modules/request/node_modules/http-signature/node_modules/ctype/ctype.js +0 -944
  223. package/node_modules/request/node_modules/http-signature/node_modules/ctype/man/man3ctype/ctio.3ctype +0 -241
  224. package/node_modules/request/node_modules/http-signature/node_modules/ctype/package.json +0 -36
  225. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tools/jsl.conf +0 -129
  226. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tools/jsstyle +0 -839
  227. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctf/float.json +0 -13
  228. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctf/int.json +0 -13
  229. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctf/psinfo.json +0 -104
  230. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctf/struct.json +0 -19
  231. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctf/tst.fail.js +0 -39
  232. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctf/tst.float.js +0 -14
  233. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctf/tst.int.js +0 -14
  234. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctf/tst.psinfo.js +0 -17
  235. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctf/tst.struct.js +0 -18
  236. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctf/tst.typedef.js +0 -15
  237. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctf/typedef.json +0 -14
  238. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctio/float/tst.rfloat.js +0 -767
  239. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctio/float/tst.wfloat.js +0 -753
  240. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctio/int/tst.64.js +0 -638
  241. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctio/int/tst.rint.js +0 -101
  242. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctio/int/tst.wbounds.js +0 -53
  243. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctio/int/tst.wint.js +0 -92
  244. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctio/uint/tst.64.js +0 -451
  245. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctio/uint/tst.roundtrip.js +0 -81
  246. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctio/uint/tst.ruint.js +0 -95
  247. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctio/uint/tst.wuint.js +0 -156
  248. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctype/tst.basicr.js +0 -50
  249. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctype/tst.basicw.js +0 -44
  250. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctype/tst.char.js +0 -42
  251. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctype/tst.endian.js +0 -45
  252. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctype/tst.oldwrite.js +0 -28
  253. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctype/tst.readSize.js +0 -128
  254. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctype/tst.structw.js +0 -28
  255. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctype/tst.writeStruct.js +0 -31
  256. package/node_modules/request/node_modules/http-signature/package.json +0 -54
  257. package/node_modules/request/node_modules/json-stringify-safe/LICENSE +0 -27
  258. package/node_modules/request/node_modules/json-stringify-safe/README.md +0 -49
  259. package/node_modules/request/node_modules/json-stringify-safe/package.json +0 -51
  260. package/node_modules/request/node_modules/json-stringify-safe/stringify.js +0 -39
  261. package/node_modules/request/node_modules/json-stringify-safe/test.js +0 -128
  262. package/node_modules/request/node_modules/mime-types/.npmignore +0 -14
  263. package/node_modules/request/node_modules/mime-types/.travis.yml +0 -12
  264. package/node_modules/request/node_modules/mime-types/LICENSE +0 -22
  265. package/node_modules/request/node_modules/mime-types/Makefile +0 -9
  266. package/node_modules/request/node_modules/mime-types/README.md +0 -101
  267. package/node_modules/request/node_modules/mime-types/SOURCES.md +0 -17
  268. package/node_modules/request/node_modules/mime-types/component.json +0 -16
  269. package/node_modules/request/node_modules/mime-types/lib/custom.json +0 -27
  270. package/node_modules/request/node_modules/mime-types/lib/index.js +0 -75
  271. package/node_modules/request/node_modules/mime-types/lib/mime.json +0 -3317
  272. package/node_modules/request/node_modules/mime-types/lib/node.json +0 -55
  273. package/node_modules/request/node_modules/mime-types/package.json +0 -69
  274. package/node_modules/request/node_modules/node-uuid/.npmignore +0 -2
  275. package/node_modules/request/node_modules/node-uuid/LICENSE.md +0 -2
  276. package/node_modules/request/node_modules/node-uuid/README.md +0 -207
  277. package/node_modules/request/node_modules/node-uuid/benchmark/README.md +0 -53
  278. package/node_modules/request/node_modules/node-uuid/benchmark/bench.gnu +0 -174
  279. package/node_modules/request/node_modules/node-uuid/benchmark/bench.sh +0 -34
  280. package/node_modules/request/node_modules/node-uuid/benchmark/benchmark-native.c +0 -34
  281. package/node_modules/request/node_modules/node-uuid/benchmark/benchmark.js +0 -84
  282. package/node_modules/request/node_modules/node-uuid/component.json +0 -18
  283. package/node_modules/request/node_modules/node-uuid/package.json +0 -54
  284. package/node_modules/request/node_modules/node-uuid/test/compare_v1.js +0 -63
  285. package/node_modules/request/node_modules/node-uuid/test/test.html +0 -17
  286. package/node_modules/request/node_modules/node-uuid/test/test.js +0 -228
  287. package/node_modules/request/node_modules/node-uuid/uuid.js +0 -245
  288. package/node_modules/request/node_modules/oauth-sign/LICENSE +0 -55
  289. package/node_modules/request/node_modules/oauth-sign/README.md +0 -4
  290. package/node_modules/request/node_modules/oauth-sign/index.js +0 -43
  291. package/node_modules/request/node_modules/oauth-sign/package.json +0 -49
  292. package/node_modules/request/node_modules/oauth-sign/test.js +0 -49
  293. package/node_modules/request/node_modules/qs/.jshintignore +0 -1
  294. package/node_modules/request/node_modules/qs/.jshintrc +0 -10
  295. package/node_modules/request/node_modules/qs/.npmignore +0 -18
  296. package/node_modules/request/node_modules/qs/.travis.yml +0 -4
  297. package/node_modules/request/node_modules/qs/LICENSE +0 -28
  298. package/node_modules/request/node_modules/qs/Makefile +0 -8
  299. package/node_modules/request/node_modules/qs/Readme.md +0 -120
  300. package/node_modules/request/node_modules/qs/index.js +0 -1
  301. package/node_modules/request/node_modules/qs/lib/index.js +0 -15
  302. package/node_modules/request/node_modules/qs/lib/parse.js +0 -151
  303. package/node_modules/request/node_modules/qs/lib/stringify.js +0 -52
  304. package/node_modules/request/node_modules/qs/lib/utils.js +0 -131
  305. package/node_modules/request/node_modules/qs/package.json +0 -61
  306. package/node_modules/request/node_modules/qs/test/parse.js +0 -236
  307. package/node_modules/request/node_modules/qs/test/stringify.js +0 -123
  308. package/node_modules/request/node_modules/stringstream/.npmignore +0 -15
  309. package/node_modules/request/node_modules/stringstream/.travis.yml +0 -4
  310. package/node_modules/request/node_modules/stringstream/LICENSE.txt +0 -4
  311. package/node_modules/request/node_modules/stringstream/README.md +0 -38
  312. package/node_modules/request/node_modules/stringstream/example.js +0 -27
  313. package/node_modules/request/node_modules/stringstream/package.json +0 -48
  314. package/node_modules/request/node_modules/stringstream/stringstream.js +0 -102
  315. package/node_modules/request/node_modules/tough-cookie/.jshintrc +0 -70
  316. package/node_modules/request/node_modules/tough-cookie/.npmignore +0 -3
  317. package/node_modules/request/node_modules/tough-cookie/.travis.yml +0 -8
  318. package/node_modules/request/node_modules/tough-cookie/LICENSE +0 -78
  319. package/node_modules/request/node_modules/tough-cookie/README.md +0 -412
  320. package/node_modules/request/node_modules/tough-cookie/generate-pubsuffix.js +0 -239
  321. package/node_modules/request/node_modules/tough-cookie/lib/cookie.js +0 -1107
  322. package/node_modules/request/node_modules/tough-cookie/lib/memstore.js +0 -123
  323. package/node_modules/request/node_modules/tough-cookie/lib/pubsuffix.js +0 -69
  324. package/node_modules/request/node_modules/tough-cookie/lib/store.js +0 -37
  325. package/node_modules/request/node_modules/tough-cookie/node_modules/punycode/LICENSE-MIT.txt +0 -20
  326. package/node_modules/request/node_modules/tough-cookie/node_modules/punycode/README.md +0 -176
  327. package/node_modules/request/node_modules/tough-cookie/node_modules/punycode/package.json +0 -87
  328. package/node_modules/request/node_modules/tough-cookie/node_modules/punycode/punycode.js +0 -528
  329. package/node_modules/request/node_modules/tough-cookie/package.json +0 -67
  330. package/node_modules/request/node_modules/tough-cookie/public-suffix.txt +0 -5229
  331. package/node_modules/request/node_modules/tough-cookie/test.js +0 -1625
  332. package/node_modules/request/node_modules/tunnel-agent/.jshintrc +0 -5
  333. package/node_modules/request/node_modules/tunnel-agent/LICENSE +0 -55
  334. package/node_modules/request/node_modules/tunnel-agent/README.md +0 -4
  335. package/node_modules/request/node_modules/tunnel-agent/index.js +0 -236
  336. package/node_modules/request/node_modules/tunnel-agent/package.json +0 -46
  337. package/node_modules/request/package.json +0 -77
  338. package/node_modules/request/request.js +0 -1428
  339. package/test/fixtures/github-response.json +0 -1367
  340. package/test/index.js +0 -55
@@ -1,60 +0,0 @@
1
- {
2
- "name": "async",
3
- "description": "Higher-order functions and common patterns for asynchronous code",
4
- "main": "./lib/async",
5
- "author": {
6
- "name": "Caolan McMahon"
7
- },
8
- "version": "0.9.0",
9
- "repository": {
10
- "type": "git",
11
- "url": "https://github.com/caolan/async.git"
12
- },
13
- "bugs": {
14
- "url": "https://github.com/caolan/async/issues"
15
- },
16
- "licenses": [
17
- {
18
- "type": "MIT",
19
- "url": "https://github.com/caolan/async/raw/master/LICENSE"
20
- }
21
- ],
22
- "devDependencies": {
23
- "nodeunit": ">0.0.0",
24
- "uglify-js": "1.2.x",
25
- "nodelint": ">0.0.0"
26
- },
27
- "jam": {
28
- "main": "lib/async.js",
29
- "include": [
30
- "lib/async.js",
31
- "README.md",
32
- "LICENSE"
33
- ]
34
- },
35
- "scripts": {
36
- "test": "nodeunit test/test-async.js"
37
- },
38
- "homepage": "https://github.com/caolan/async",
39
- "_id": "async@0.9.0",
40
- "dist": {
41
- "shasum": "ac3613b1da9bed1b47510bb4651b8931e47146c7",
42
- "tarball": "http://registry.npmjs.org/async/-/async-0.9.0.tgz"
43
- },
44
- "_from": "async@~0.9.0",
45
- "_npmVersion": "1.4.3",
46
- "_npmUser": {
47
- "name": "caolan",
48
- "email": "caolan.mcmahon@gmail.com"
49
- },
50
- "maintainers": [
51
- {
52
- "name": "caolan",
53
- "email": "caolan@caolanmcmahon.com"
54
- }
55
- ],
56
- "directories": {},
57
- "_shasum": "ac3613b1da9bed1b47510bb4651b8931e47146c7",
58
- "_resolved": "https://registry.npmjs.org/async/-/async-0.9.0.tgz",
59
- "readme": "ERROR: No README data found!"
60
- }
@@ -1,19 +0,0 @@
1
- Copyright (c) 2011 Debuggable Limited <felix@debuggable.com>
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.
@@ -1,132 +0,0 @@
1
- # combined-stream [![Build Status](https://travis-ci.org/felixge/node-combined-stream.svg?branch=master)](https://travis-ci.org/felixge/node-combined-stream)
2
-
3
- A stream that emits multiple other streams one after another.
4
-
5
- ## Installation
6
-
7
- ``` bash
8
- npm install combined-stream
9
- ```
10
-
11
- ## Usage
12
-
13
- Here is a simple example that shows how you can use combined-stream to combine
14
- two files into one:
15
-
16
- ``` javascript
17
- var CombinedStream = require('combined-stream');
18
- var fs = require('fs');
19
-
20
- var combinedStream = CombinedStream.create();
21
- combinedStream.append(fs.createReadStream('file1.txt'));
22
- combinedStream.append(fs.createReadStream('file2.txt'));
23
-
24
- combinedStream.pipe(fs.createWriteStream('combined.txt'));
25
- ```
26
-
27
- While the example above works great, it will pause all source streams until
28
- they are needed. If you don't want that to happen, you can set `pauseStreams`
29
- to `false`:
30
-
31
- ``` javascript
32
- var CombinedStream = require('combined-stream');
33
- var fs = require('fs');
34
-
35
- var combinedStream = CombinedStream.create({pauseStreams: false});
36
- combinedStream.append(fs.createReadStream('file1.txt'));
37
- combinedStream.append(fs.createReadStream('file2.txt'));
38
-
39
- combinedStream.pipe(fs.createWriteStream('combined.txt'));
40
- ```
41
-
42
- However, what if you don't have all the source streams yet, or you don't want
43
- to allocate the resources (file descriptors, memory, etc.) for them right away?
44
- Well, in that case you can simply provide a callback that supplies the stream
45
- by calling a `next()` function:
46
-
47
- ``` javascript
48
- var CombinedStream = require('combined-stream');
49
- var fs = require('fs');
50
-
51
- var combinedStream = CombinedStream.create();
52
- combinedStream.append(function(next) {
53
- next(fs.createReadStream('file1.txt'));
54
- });
55
- combinedStream.append(function(next) {
56
- next(fs.createReadStream('file2.txt'));
57
- });
58
-
59
- combinedStream.pipe(fs.createWriteStream('combined.txt'));
60
- ```
61
-
62
- ## API
63
-
64
- ### CombinedStream.create([options])
65
-
66
- Returns a new combined stream object. Available options are:
67
-
68
- * `maxDataSize`
69
- * `pauseStreams`
70
-
71
- The effect of those options is described below.
72
-
73
- ### combinedStream.pauseStreams = `true`
74
-
75
- Whether to apply back pressure to the underlaying streams. If set to `false`,
76
- the underlaying streams will never be paused. If set to `true`, the
77
- underlaying streams will be paused right after being appended, as well as when
78
- `delayedStream.pipe()` wants to throttle.
79
-
80
- ### combinedStream.maxDataSize = `2 * 1024 * 1024`
81
-
82
- The maximum amount of bytes (or characters) to buffer for all source streams.
83
- If this value is exceeded, `combinedStream` emits an `'error'` event.
84
-
85
- ### combinedStream.dataSize = `0`
86
-
87
- The amount of bytes (or characters) currently buffered by `combinedStream`.
88
-
89
- ### combinedStream.append(stream)
90
-
91
- Appends the given `stream` to the combinedStream object. If `pauseStreams` is
92
- set to `true, this stream will also be paused right away.
93
-
94
- `streams` can also be a function that takes one parameter called `next`. `next`
95
- is a function that must be invoked in order to provide the `next` stream, see
96
- example above.
97
-
98
- Regardless of how the `stream` is appended, combined-stream always attaches an
99
- `'error'` listener to it, so you don't have to do that manually.
100
-
101
- Special case: `stream` can also be a String or Buffer.
102
-
103
- ### combinedStream.write(data)
104
-
105
- You should not call this, `combinedStream` takes care of piping the appended
106
- streams into itself for you.
107
-
108
- ### combinedStream.resume()
109
-
110
- Causes `combinedStream` to start drain the streams it manages. The function is
111
- idempotent, and also emits a `'resume'` event each time which usually goes to
112
- the stream that is currently being drained.
113
-
114
- ### combinedStream.pause();
115
-
116
- If `combinedStream.pauseStreams` is set to `false`, this does nothing.
117
- Otherwise a `'pause'` event is emitted, this goes to the stream that is
118
- currently being drained, so you can use it to apply back pressure.
119
-
120
- ### combinedStream.end();
121
-
122
- Sets `combinedStream.writable` to false, emits an `'end'` event, and removes
123
- all streams from the queue.
124
-
125
- ### combinedStream.destroy();
126
-
127
- Same as `combinedStream.end()`, except it emits a `'close'` event instead of
128
- `'end'`.
129
-
130
- ## License
131
-
132
- combined-stream is licensed under the MIT license.
@@ -1,186 +0,0 @@
1
- var util = require('util');
2
- var Stream = require('stream').Stream;
3
- var DelayedStream = require('delayed-stream');
4
-
5
- module.exports = CombinedStream;
6
- function CombinedStream() {
7
- this.writable = false;
8
- this.readable = true;
9
- this.dataSize = 0;
10
- this.maxDataSize = 2 * 1024 * 1024;
11
- this.pauseStreams = true;
12
-
13
- this._released = false;
14
- this._streams = [];
15
- this._currentStream = null;
16
- }
17
- util.inherits(CombinedStream, Stream);
18
-
19
- CombinedStream.create = function(options) {
20
- var combinedStream = new this();
21
-
22
- options = options || {};
23
- for (var option in options) {
24
- combinedStream[option] = options[option];
25
- }
26
-
27
- return combinedStream;
28
- };
29
-
30
- CombinedStream.isStreamLike = function(stream) {
31
- return (typeof stream !== 'function')
32
- && (typeof stream !== 'string')
33
- && (typeof stream !== 'boolean')
34
- && (typeof stream !== 'number')
35
- && (!Buffer.isBuffer(stream));
36
- };
37
-
38
- CombinedStream.prototype.append = function(stream) {
39
- var isStreamLike = CombinedStream.isStreamLike(stream);
40
-
41
- if (isStreamLike) {
42
- if (!(stream instanceof DelayedStream)) {
43
- stream.on('data', this._checkDataSize.bind(this));
44
-
45
- stream = DelayedStream.create(stream, {
46
- maxDataSize: Infinity,
47
- pauseStream: this.pauseStreams,
48
- });
49
- }
50
-
51
- this._handleErrors(stream);
52
-
53
- if (this.pauseStreams) {
54
- stream.pause();
55
- }
56
- }
57
-
58
- this._streams.push(stream);
59
- return this;
60
- };
61
-
62
- CombinedStream.prototype.pipe = function(dest, options) {
63
- Stream.prototype.pipe.call(this, dest, options);
64
- this.resume();
65
- return dest;
66
- };
67
-
68
- CombinedStream.prototype._getNext = function() {
69
- this._currentStream = null;
70
- var stream = this._streams.shift();
71
-
72
-
73
- if (typeof stream == 'undefined') {
74
- this.end();
75
- return;
76
- }
77
-
78
- if (typeof stream !== 'function') {
79
- this._pipeNext(stream);
80
- return;
81
- }
82
-
83
- var getStream = stream;
84
- getStream(function(stream) {
85
- var isStreamLike = CombinedStream.isStreamLike(stream);
86
- if (isStreamLike) {
87
- stream.on('data', this._checkDataSize.bind(this));
88
- this._handleErrors(stream);
89
- }
90
-
91
- this._pipeNext(stream);
92
- }.bind(this));
93
- };
94
-
95
- CombinedStream.prototype._pipeNext = function(stream) {
96
- this._currentStream = stream;
97
-
98
- var isStreamLike = CombinedStream.isStreamLike(stream);
99
- if (isStreamLike) {
100
- stream.on('end', this._getNext.bind(this))
101
- stream.pipe(this, {end: false});
102
- return;
103
- }
104
-
105
- var value = stream;
106
- this.write(value);
107
- this._getNext();
108
- };
109
-
110
- CombinedStream.prototype._handleErrors = function(stream) {
111
- var self = this;
112
- stream.on('error', function(err) {
113
- self._emitError(err);
114
- });
115
- };
116
-
117
- CombinedStream.prototype.write = function(data) {
118
- this.emit('data', data);
119
- };
120
-
121
- CombinedStream.prototype.pause = function() {
122
- if (!this.pauseStreams) {
123
- return;
124
- }
125
-
126
- this.emit('pause');
127
- };
128
-
129
- CombinedStream.prototype.resume = function() {
130
- if (!this._released) {
131
- this._released = true;
132
- this.writable = true;
133
- this._getNext();
134
- }
135
-
136
- this.emit('resume');
137
- };
138
-
139
- CombinedStream.prototype.end = function() {
140
- this._reset();
141
- this.emit('end');
142
- };
143
-
144
- CombinedStream.prototype.destroy = function() {
145
- this._reset();
146
- this.emit('close');
147
- };
148
-
149
- CombinedStream.prototype._reset = function() {
150
- this.writable = false;
151
- this._streams = [];
152
- this._currentStream = null;
153
- };
154
-
155
- CombinedStream.prototype._checkDataSize = function() {
156
- this._updateDataSize();
157
- if (this.dataSize <= this.maxDataSize) {
158
- return;
159
- }
160
-
161
- var message =
162
- 'DelayedStream#maxDataSize of ' + this.maxDataSize + ' bytes exceeded.'
163
- this._emitError(new Error(message));
164
- };
165
-
166
- CombinedStream.prototype._updateDataSize = function() {
167
- this.dataSize = 0;
168
-
169
- var self = this;
170
- this._streams.forEach(function(stream) {
171
- if (!stream.dataSize) {
172
- return;
173
- }
174
-
175
- self.dataSize += stream.dataSize;
176
- });
177
-
178
- if (this._currentStream && this._currentStream.dataSize) {
179
- this.dataSize += this._currentStream.dataSize;
180
- }
181
- };
182
-
183
- CombinedStream.prototype._emitError = function(err) {
184
- this._reset();
185
- this.emit('error', err);
186
- };
@@ -1,19 +0,0 @@
1
- Copyright (c) 2011 Debuggable Limited <felix@debuggable.com>
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.
@@ -1,7 +0,0 @@
1
- SHELL := /bin/bash
2
-
3
- test:
4
- @./test/run.js
5
-
6
- .PHONY: test
7
-
@@ -1,154 +0,0 @@
1
- # delayed-stream
2
-
3
- Buffers events from a stream until you are ready to handle them.
4
-
5
- ## Installation
6
-
7
- ``` bash
8
- npm install delayed-stream
9
- ```
10
-
11
- ## Usage
12
-
13
- The following example shows how to write a http echo server that delays its
14
- response by 1000 ms.
15
-
16
- ``` javascript
17
- var DelayedStream = require('delayed-stream');
18
- var http = require('http');
19
-
20
- http.createServer(function(req, res) {
21
- var delayed = DelayedStream.create(req);
22
-
23
- setTimeout(function() {
24
- res.writeHead(200);
25
- delayed.pipe(res);
26
- }, 1000);
27
- });
28
- ```
29
-
30
- If you are not using `Stream#pipe`, you can also manually release the buffered
31
- events by calling `delayedStream.resume()`:
32
-
33
- ``` javascript
34
- var delayed = DelayedStream.create(req);
35
-
36
- setTimeout(function() {
37
- // Emit all buffered events and resume underlaying source
38
- delayed.resume();
39
- }, 1000);
40
- ```
41
-
42
- ## Implementation
43
-
44
- In order to use this meta stream properly, here are a few things you should
45
- know about the implementation.
46
-
47
- ### Event Buffering / Proxying
48
-
49
- All events of the `source` stream are hijacked by overwriting the `source.emit`
50
- method. Until node implements a catch-all event listener, this is the only way.
51
-
52
- However, delayed-stream still continues to emit all events it captures on the
53
- `source`, regardless of whether you have released the delayed stream yet or
54
- not.
55
-
56
- Upon creation, delayed-stream captures all `source` events and stores them in
57
- an internal event buffer. Once `delayedStream.release()` is called, all
58
- buffered events are emitted on the `delayedStream`, and the event buffer is
59
- cleared. After that, delayed-stream merely acts as a proxy for the underlaying
60
- source.
61
-
62
- ### Error handling
63
-
64
- Error events on `source` are buffered / proxied just like any other events.
65
- However, `delayedStream.create` attaches a no-op `'error'` listener to the
66
- `source`. This way you only have to handle errors on the `delayedStream`
67
- object, rather than in two places.
68
-
69
- ### Buffer limits
70
-
71
- delayed-stream provides a `maxDataSize` property that can be used to limit
72
- the amount of data being buffered. In order to protect you from bad `source`
73
- streams that don't react to `source.pause()`, this feature is enabled by
74
- default.
75
-
76
- ## API
77
-
78
- ### DelayedStream.create(source, [options])
79
-
80
- Returns a new `delayedStream`. Available options are:
81
-
82
- * `pauseStream`
83
- * `maxDataSize`
84
-
85
- The description for those properties can be found below.
86
-
87
- ### delayedStream.source
88
-
89
- The `source` stream managed by this object. This is useful if you are
90
- passing your `delayedStream` around, and you still want to access properties
91
- on the `source` object.
92
-
93
- ### delayedStream.pauseStream = true
94
-
95
- Whether to pause the underlaying `source` when calling
96
- `DelayedStream.create()`. Modifying this property afterwards has no effect.
97
-
98
- ### delayedStream.maxDataSize = 1024 * 1024
99
-
100
- The amount of data to buffer before emitting an `error`.
101
-
102
- If the underlaying source is emitting `Buffer` objects, the `maxDataSize`
103
- refers to bytes.
104
-
105
- If the underlaying source is emitting JavaScript strings, the size refers to
106
- characters.
107
-
108
- If you know what you are doing, you can set this property to `Infinity` to
109
- disable this feature. You can also modify this property during runtime.
110
-
111
- ### delayedStream.maxDataSize = 1024 * 1024
112
-
113
- The amount of data to buffer before emitting an `error`.
114
-
115
- If the underlaying source is emitting `Buffer` objects, the `maxDataSize`
116
- refers to bytes.
117
-
118
- If the underlaying source is emitting JavaScript strings, the size refers to
119
- characters.
120
-
121
- If you know what you are doing, you can set this property to `Infinity` to
122
- disable this feature.
123
-
124
- ### delayedStream.dataSize = 0
125
-
126
- The amount of data buffered so far.
127
-
128
- ### delayedStream.readable
129
-
130
- An ECMA5 getter that returns the value of `source.readable`.
131
-
132
- ### delayedStream.resume()
133
-
134
- If the `delayedStream` has not been released so far, `delayedStream.release()`
135
- is called.
136
-
137
- In either case, `source.resume()` is called.
138
-
139
- ### delayedStream.pause()
140
-
141
- Calls `source.pause()`.
142
-
143
- ### delayedStream.pipe(dest)
144
-
145
- Calls `delayedStream.resume()` and then proxies the arguments to `source.pipe`.
146
-
147
- ### delayedStream.release()
148
-
149
- Emits and clears all events that have been buffered up so far. This does not
150
- resume the underlaying source, use `delayedStream.resume()` instead.
151
-
152
- ## License
153
-
154
- delayed-stream is licensed under the MIT license.
@@ -1,99 +0,0 @@
1
- var Stream = require('stream').Stream;
2
- var util = require('util');
3
-
4
- module.exports = DelayedStream;
5
- function DelayedStream() {
6
- this.source = null;
7
- this.dataSize = 0;
8
- this.maxDataSize = 1024 * 1024;
9
- this.pauseStream = true;
10
-
11
- this._maxDataSizeExceeded = false;
12
- this._released = false;
13
- this._bufferedEvents = [];
14
- }
15
- util.inherits(DelayedStream, Stream);
16
-
17
- DelayedStream.create = function(source, options) {
18
- var delayedStream = new this();
19
-
20
- options = options || {};
21
- for (var option in options) {
22
- delayedStream[option] = options[option];
23
- }
24
-
25
- delayedStream.source = source;
26
-
27
- var realEmit = source.emit;
28
- source.emit = function() {
29
- delayedStream._handleEmit(arguments);
30
- return realEmit.apply(source, arguments);
31
- };
32
-
33
- source.on('error', function() {});
34
- if (delayedStream.pauseStream) {
35
- source.pause();
36
- }
37
-
38
- return delayedStream;
39
- };
40
-
41
- DelayedStream.prototype.__defineGetter__('readable', function() {
42
- return this.source.readable;
43
- });
44
-
45
- DelayedStream.prototype.resume = function() {
46
- if (!this._released) {
47
- this.release();
48
- }
49
-
50
- this.source.resume();
51
- };
52
-
53
- DelayedStream.prototype.pause = function() {
54
- this.source.pause();
55
- };
56
-
57
- DelayedStream.prototype.release = function() {
58
- this._released = true;
59
-
60
- this._bufferedEvents.forEach(function(args) {
61
- this.emit.apply(this, args);
62
- }.bind(this));
63
- this._bufferedEvents = [];
64
- };
65
-
66
- DelayedStream.prototype.pipe = function() {
67
- var r = Stream.prototype.pipe.apply(this, arguments);
68
- this.resume();
69
- return r;
70
- };
71
-
72
- DelayedStream.prototype._handleEmit = function(args) {
73
- if (this._released) {
74
- this.emit.apply(this, args);
75
- return;
76
- }
77
-
78
- if (args[0] === 'data') {
79
- this.dataSize += args[1].length;
80
- this._checkIfMaxDataSizeExceeded();
81
- }
82
-
83
- this._bufferedEvents.push(args);
84
- };
85
-
86
- DelayedStream.prototype._checkIfMaxDataSizeExceeded = function() {
87
- if (this._maxDataSizeExceeded) {
88
- return;
89
- }
90
-
91
- if (this.dataSize <= this.maxDataSize) {
92
- return;
93
- }
94
-
95
- this._maxDataSizeExceeded = true;
96
- var message =
97
- 'DelayedStream#maxDataSize of ' + this.maxDataSize + ' bytes exceeded.'
98
- this.emit('error', new Error(message));
99
- };