rahad-media-downloader 2.1.12 → 2.1.13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (232) hide show
  1. package/.cache/replit/modules/nodejs-20.res +1 -0
  2. package/.cache/replit/modules/replit.res +1 -0
  3. package/.cache/typescript/5.4/node_modules/.package-lock.json +185 -0
  4. package/.cache/typescript/5.4/node_modules/@types/caseless/LICENSE +21 -0
  5. package/.cache/typescript/5.4/node_modules/@types/caseless/README.md +48 -0
  6. package/.cache/typescript/5.4/node_modules/@types/caseless/index.d.ts +29 -0
  7. package/.cache/typescript/5.4/node_modules/@types/caseless/package.json +35 -0
  8. package/.cache/typescript/5.4/node_modules/@types/domhandler/LICENSE +21 -0
  9. package/.cache/typescript/5.4/node_modules/@types/domhandler/README.md +92 -0
  10. package/.cache/typescript/5.4/node_modules/@types/domhandler/index.d.ts +73 -0
  11. package/.cache/typescript/5.4/node_modules/@types/domhandler/package.json +25 -0
  12. package/.cache/typescript/5.4/node_modules/@types/domutils/LICENSE +21 -0
  13. package/.cache/typescript/5.4/node_modules/@types/domutils/README.md +15 -0
  14. package/.cache/typescript/5.4/node_modules/@types/domutils/index.d.ts +124 -0
  15. package/.cache/typescript/5.4/node_modules/@types/domutils/package.json +27 -0
  16. package/.cache/typescript/5.4/node_modules/@types/htmlparser2/LICENSE +21 -0
  17. package/.cache/typescript/5.4/node_modules/@types/htmlparser2/README.md +15 -0
  18. package/.cache/typescript/5.4/node_modules/@types/htmlparser2/index.d.ts +120 -0
  19. package/.cache/typescript/5.4/node_modules/@types/htmlparser2/package.json +45 -0
  20. package/.cache/typescript/5.4/node_modules/@types/node/LICENSE +21 -0
  21. package/.cache/typescript/5.4/node_modules/@types/node/README.md +15 -0
  22. package/.cache/typescript/5.4/node_modules/@types/node/assert/strict.d.ts +8 -0
  23. package/.cache/typescript/5.4/node_modules/@types/node/assert.d.ts +1040 -0
  24. package/.cache/typescript/5.4/node_modules/@types/node/async_hooks.d.ts +541 -0
  25. package/.cache/typescript/5.4/node_modules/@types/node/buffer.d.ts +2363 -0
  26. package/.cache/typescript/5.4/node_modules/@types/node/child_process.d.ts +1542 -0
  27. package/.cache/typescript/5.4/node_modules/@types/node/cluster.d.ts +578 -0
  28. package/.cache/typescript/5.4/node_modules/@types/node/console.d.ts +452 -0
  29. package/.cache/typescript/5.4/node_modules/@types/node/constants.d.ts +19 -0
  30. package/.cache/typescript/5.4/node_modules/@types/node/crypto.d.ts +4522 -0
  31. package/.cache/typescript/5.4/node_modules/@types/node/dgram.d.ts +596 -0
  32. package/.cache/typescript/5.4/node_modules/@types/node/diagnostics_channel.d.ts +545 -0
  33. package/.cache/typescript/5.4/node_modules/@types/node/dns/promises.d.ts +473 -0
  34. package/.cache/typescript/5.4/node_modules/@types/node/dns.d.ts +853 -0
  35. package/.cache/typescript/5.4/node_modules/@types/node/dom-events.d.ts +124 -0
  36. package/.cache/typescript/5.4/node_modules/@types/node/domain.d.ts +170 -0
  37. package/.cache/typescript/5.4/node_modules/@types/node/events.d.ts +884 -0
  38. package/.cache/typescript/5.4/node_modules/@types/node/fs/promises.d.ts +1245 -0
  39. package/.cache/typescript/5.4/node_modules/@types/node/fs.d.ts +4317 -0
  40. package/.cache/typescript/5.4/node_modules/@types/node/globals.d.ts +411 -0
  41. package/.cache/typescript/5.4/node_modules/@types/node/globals.global.d.ts +1 -0
  42. package/.cache/typescript/5.4/node_modules/@types/node/http.d.ts +1889 -0
  43. package/.cache/typescript/5.4/node_modules/@types/node/http2.d.ts +2418 -0
  44. package/.cache/typescript/5.4/node_modules/@types/node/https.d.ts +550 -0
  45. package/.cache/typescript/5.4/node_modules/@types/node/index.d.ts +89 -0
  46. package/.cache/typescript/5.4/node_modules/@types/node/inspector.d.ts +2746 -0
  47. package/.cache/typescript/5.4/node_modules/@types/node/module.d.ts +315 -0
  48. package/.cache/typescript/5.4/node_modules/@types/node/net.d.ts +996 -0
  49. package/.cache/typescript/5.4/node_modules/@types/node/os.d.ts +495 -0
  50. package/.cache/typescript/5.4/node_modules/@types/node/package.json +217 -0
  51. package/.cache/typescript/5.4/node_modules/@types/node/path.d.ts +191 -0
  52. package/.cache/typescript/5.4/node_modules/@types/node/perf_hooks.d.ts +645 -0
  53. package/.cache/typescript/5.4/node_modules/@types/node/process.d.ts +1747 -0
  54. package/.cache/typescript/5.4/node_modules/@types/node/punycode.d.ts +117 -0
  55. package/.cache/typescript/5.4/node_modules/@types/node/querystring.d.ts +153 -0
  56. package/.cache/typescript/5.4/node_modules/@types/node/readline/promises.d.ts +150 -0
  57. package/.cache/typescript/5.4/node_modules/@types/node/readline.d.ts +540 -0
  58. package/.cache/typescript/5.4/node_modules/@types/node/repl.d.ts +430 -0
  59. package/.cache/typescript/5.4/node_modules/@types/node/sea.d.ts +153 -0
  60. package/.cache/typescript/5.4/node_modules/@types/node/stream/consumers.d.ts +12 -0
  61. package/.cache/typescript/5.4/node_modules/@types/node/stream/promises.d.ts +83 -0
  62. package/.cache/typescript/5.4/node_modules/@types/node/stream/web.d.ts +367 -0
  63. package/.cache/typescript/5.4/node_modules/@types/node/stream.d.ts +1707 -0
  64. package/.cache/typescript/5.4/node_modules/@types/node/string_decoder.d.ts +67 -0
  65. package/.cache/typescript/5.4/node_modules/@types/node/test.d.ts +1470 -0
  66. package/.cache/typescript/5.4/node_modules/@types/node/timers/promises.d.ts +97 -0
  67. package/.cache/typescript/5.4/node_modules/@types/node/timers.d.ts +240 -0
  68. package/.cache/typescript/5.4/node_modules/@types/node/tls.d.ts +1217 -0
  69. package/.cache/typescript/5.4/node_modules/@types/node/trace_events.d.ts +197 -0
  70. package/.cache/typescript/5.4/node_modules/@types/node/tty.d.ts +208 -0
  71. package/.cache/typescript/5.4/node_modules/@types/node/url.d.ts +944 -0
  72. package/.cache/typescript/5.4/node_modules/@types/node/util.d.ts +2276 -0
  73. package/.cache/typescript/5.4/node_modules/@types/node/v8.d.ts +764 -0
  74. package/.cache/typescript/5.4/node_modules/@types/node/vm.d.ts +921 -0
  75. package/.cache/typescript/5.4/node_modules/@types/node/wasi.d.ts +181 -0
  76. package/.cache/typescript/5.4/node_modules/@types/node/worker_threads.d.ts +691 -0
  77. package/.cache/typescript/5.4/node_modules/@types/node/zlib.d.ts +530 -0
  78. package/.cache/typescript/5.4/node_modules/@types/node-fetch/LICENSE +21 -0
  79. package/.cache/typescript/5.4/node_modules/@types/node-fetch/README.md +15 -0
  80. package/.cache/typescript/5.4/node_modules/@types/node-fetch/externals.d.ts +32 -0
  81. package/.cache/typescript/5.4/node_modules/@types/node-fetch/index.d.ts +238 -0
  82. package/.cache/typescript/5.4/node_modules/@types/node-fetch/package.json +83 -0
  83. package/.cache/typescript/5.4/node_modules/@types/qs/LICENSE +21 -0
  84. package/.cache/typescript/5.4/node_modules/@types/qs/README.md +15 -0
  85. package/.cache/typescript/5.4/node_modules/@types/qs/index.d.ts +79 -0
  86. package/.cache/typescript/5.4/node_modules/@types/qs/package.json +65 -0
  87. package/.cache/typescript/5.4/node_modules/@types/request/LICENSE +21 -0
  88. package/.cache/typescript/5.4/node_modules/@types/request/README.md +15 -0
  89. package/.cache/typescript/5.4/node_modules/@types/request/index.d.ts +395 -0
  90. package/.cache/typescript/5.4/node_modules/@types/request/node_modules/form-data/License +19 -0
  91. package/.cache/typescript/5.4/node_modules/@types/request/node_modules/form-data/README.md +350 -0
  92. package/.cache/typescript/5.4/node_modules/@types/request/node_modules/form-data/README.md.bak +350 -0
  93. package/.cache/typescript/5.4/node_modules/@types/request/node_modules/form-data/index.d.ts +51 -0
  94. package/.cache/typescript/5.4/node_modules/@types/request/node_modules/form-data/lib/browser.js +2 -0
  95. package/.cache/typescript/5.4/node_modules/@types/request/node_modules/form-data/lib/form_data.js +483 -0
  96. package/.cache/typescript/5.4/node_modules/@types/request/node_modules/form-data/lib/populate.js +10 -0
  97. package/.cache/typescript/5.4/node_modules/@types/request/node_modules/form-data/package.json +68 -0
  98. package/.cache/typescript/5.4/node_modules/@types/request/package.json +70 -0
  99. package/.cache/typescript/5.4/node_modules/@types/tough-cookie/LICENSE +21 -0
  100. package/.cache/typescript/5.4/node_modules/@types/tough-cookie/README.md +15 -0
  101. package/.cache/typescript/5.4/node_modules/@types/tough-cookie/index.d.ts +321 -0
  102. package/.cache/typescript/5.4/node_modules/@types/tough-cookie/package.json +35 -0
  103. package/.cache/typescript/5.4/node_modules/asynckit/LICENSE +21 -0
  104. package/.cache/typescript/5.4/node_modules/asynckit/README.md +233 -0
  105. package/.cache/typescript/5.4/node_modules/asynckit/bench.js +76 -0
  106. package/.cache/typescript/5.4/node_modules/asynckit/index.js +6 -0
  107. package/.cache/typescript/5.4/node_modules/asynckit/lib/abort.js +29 -0
  108. package/.cache/typescript/5.4/node_modules/asynckit/lib/async.js +34 -0
  109. package/.cache/typescript/5.4/node_modules/asynckit/lib/defer.js +26 -0
  110. package/.cache/typescript/5.4/node_modules/asynckit/lib/iterate.js +75 -0
  111. package/.cache/typescript/5.4/node_modules/asynckit/lib/readable_asynckit.js +91 -0
  112. package/.cache/typescript/5.4/node_modules/asynckit/lib/readable_parallel.js +25 -0
  113. package/.cache/typescript/5.4/node_modules/asynckit/lib/readable_serial.js +25 -0
  114. package/.cache/typescript/5.4/node_modules/asynckit/lib/readable_serial_ordered.js +29 -0
  115. package/.cache/typescript/5.4/node_modules/asynckit/lib/state.js +37 -0
  116. package/.cache/typescript/5.4/node_modules/asynckit/lib/streamify.js +141 -0
  117. package/.cache/typescript/5.4/node_modules/asynckit/lib/terminator.js +29 -0
  118. package/.cache/typescript/5.4/node_modules/asynckit/package.json +63 -0
  119. package/.cache/typescript/5.4/node_modules/asynckit/parallel.js +43 -0
  120. package/.cache/typescript/5.4/node_modules/asynckit/serial.js +17 -0
  121. package/.cache/typescript/5.4/node_modules/asynckit/serialOrdered.js +75 -0
  122. package/.cache/typescript/5.4/node_modules/asynckit/stream.js +21 -0
  123. package/.cache/typescript/5.4/node_modules/combined-stream/License +19 -0
  124. package/.cache/typescript/5.4/node_modules/combined-stream/Readme.md +138 -0
  125. package/.cache/typescript/5.4/node_modules/combined-stream/lib/combined_stream.js +208 -0
  126. package/.cache/typescript/5.4/node_modules/combined-stream/package.json +25 -0
  127. package/.cache/typescript/5.4/node_modules/combined-stream/yarn.lock +17 -0
  128. package/.cache/typescript/5.4/node_modules/delayed-stream/License +19 -0
  129. package/.cache/typescript/5.4/node_modules/delayed-stream/Makefile +7 -0
  130. package/.cache/typescript/5.4/node_modules/delayed-stream/Readme.md +141 -0
  131. package/.cache/typescript/5.4/node_modules/delayed-stream/lib/delayed_stream.js +107 -0
  132. package/.cache/typescript/5.4/node_modules/delayed-stream/package.json +27 -0
  133. package/.cache/typescript/5.4/node_modules/domelementtype/LICENSE +11 -0
  134. package/.cache/typescript/5.4/node_modules/domelementtype/index.js +15 -0
  135. package/.cache/typescript/5.4/node_modules/domelementtype/package.json +16 -0
  136. package/.cache/typescript/5.4/node_modules/domelementtype/readme.md +1 -0
  137. package/.cache/typescript/5.4/node_modules/domhandler/.travis.yml +6 -0
  138. package/.cache/typescript/5.4/node_modules/domhandler/LICENSE +11 -0
  139. package/.cache/typescript/5.4/node_modules/domhandler/index.js +217 -0
  140. package/.cache/typescript/5.4/node_modules/domhandler/lib/element.js +20 -0
  141. package/.cache/typescript/5.4/node_modules/domhandler/lib/node.js +44 -0
  142. package/.cache/typescript/5.4/node_modules/domhandler/package.json +41 -0
  143. package/.cache/typescript/5.4/node_modules/domhandler/readme.md +116 -0
  144. package/.cache/typescript/5.4/node_modules/domhandler/test/cases/01-basic.json +57 -0
  145. package/.cache/typescript/5.4/node_modules/domhandler/test/cases/02-single_tag_1.json +21 -0
  146. package/.cache/typescript/5.4/node_modules/domhandler/test/cases/03-single_tag_2.json +21 -0
  147. package/.cache/typescript/5.4/node_modules/domhandler/test/cases/04-unescaped_in_script.json +27 -0
  148. package/.cache/typescript/5.4/node_modules/domhandler/test/cases/05-tags_in_comment.json +18 -0
  149. package/.cache/typescript/5.4/node_modules/domhandler/test/cases/06-comment_in_script.json +18 -0
  150. package/.cache/typescript/5.4/node_modules/domhandler/test/cases/07-unescaped_in_style.json +20 -0
  151. package/.cache/typescript/5.4/node_modules/domhandler/test/cases/08-extra_spaces_in_tag.json +20 -0
  152. package/.cache/typescript/5.4/node_modules/domhandler/test/cases/09-unquoted_attrib.json +20 -0
  153. package/.cache/typescript/5.4/node_modules/domhandler/test/cases/10-singular_attribute.json +15 -0
  154. package/.cache/typescript/5.4/node_modules/domhandler/test/cases/11-text_outside_tags.json +40 -0
  155. package/.cache/typescript/5.4/node_modules/domhandler/test/cases/12-text_only.json +11 -0
  156. package/.cache/typescript/5.4/node_modules/domhandler/test/cases/13-comment_in_text.json +19 -0
  157. package/.cache/typescript/5.4/node_modules/domhandler/test/cases/14-comment_in_text_in_script.json +18 -0
  158. package/.cache/typescript/5.4/node_modules/domhandler/test/cases/15-non-verbose.json +22 -0
  159. package/.cache/typescript/5.4/node_modules/domhandler/test/cases/16-normalize_whitespace.json +47 -0
  160. package/.cache/typescript/5.4/node_modules/domhandler/test/cases/17-xml_namespace.json +18 -0
  161. package/.cache/typescript/5.4/node_modules/domhandler/test/cases/18-enforce_empty_tags.json +16 -0
  162. package/.cache/typescript/5.4/node_modules/domhandler/test/cases/19-ignore_empty_tags.json +20 -0
  163. package/.cache/typescript/5.4/node_modules/domhandler/test/cases/20-template_script_tags.json +20 -0
  164. package/.cache/typescript/5.4/node_modules/domhandler/test/cases/21-conditional_comments.json +15 -0
  165. package/.cache/typescript/5.4/node_modules/domhandler/test/cases/22-lowercase_tags.json +41 -0
  166. package/.cache/typescript/5.4/node_modules/domhandler/test/cases/23-dom-lvl1.json +131 -0
  167. package/.cache/typescript/5.4/node_modules/domhandler/test/cases/24-with-start-indices.json +85 -0
  168. package/.cache/typescript/5.4/node_modules/domhandler/test/cases/25-with-end-indices.json +86 -0
  169. package/.cache/typescript/5.4/node_modules/domhandler/test/tests.js +60 -0
  170. package/.cache/typescript/5.4/node_modules/form-data/License +19 -0
  171. package/.cache/typescript/5.4/node_modules/form-data/README.md.bak +358 -0
  172. package/.cache/typescript/5.4/node_modules/form-data/Readme.md +358 -0
  173. package/.cache/typescript/5.4/node_modules/form-data/index.d.ts +62 -0
  174. package/.cache/typescript/5.4/node_modules/form-data/lib/browser.js +2 -0
  175. package/.cache/typescript/5.4/node_modules/form-data/lib/form_data.js +501 -0
  176. package/.cache/typescript/5.4/node_modules/form-data/lib/populate.js +10 -0
  177. package/.cache/typescript/5.4/node_modules/form-data/package.json +68 -0
  178. package/.cache/typescript/5.4/node_modules/mime-db/HISTORY.md +507 -0
  179. package/.cache/typescript/5.4/node_modules/mime-db/LICENSE +23 -0
  180. package/.cache/typescript/5.4/node_modules/mime-db/README.md +100 -0
  181. package/.cache/typescript/5.4/node_modules/mime-db/db.json +8519 -0
  182. package/.cache/typescript/5.4/node_modules/mime-db/index.js +12 -0
  183. package/.cache/typescript/5.4/node_modules/mime-db/package.json +60 -0
  184. package/.cache/typescript/5.4/node_modules/mime-types/HISTORY.md +397 -0
  185. package/.cache/typescript/5.4/node_modules/mime-types/LICENSE +23 -0
  186. package/.cache/typescript/5.4/node_modules/mime-types/README.md +113 -0
  187. package/.cache/typescript/5.4/node_modules/mime-types/index.js +188 -0
  188. package/.cache/typescript/5.4/node_modules/mime-types/package.json +44 -0
  189. package/.cache/typescript/5.4/node_modules/types-registry/README.md +2 -0
  190. package/.cache/typescript/5.4/node_modules/types-registry/index.json +1 -0
  191. package/.cache/typescript/5.4/node_modules/types-registry/package.json +20 -0
  192. package/.cache/typescript/5.4/node_modules/undici-types/README.md +6 -0
  193. package/.cache/typescript/5.4/node_modules/undici-types/agent.d.ts +31 -0
  194. package/.cache/typescript/5.4/node_modules/undici-types/api.d.ts +43 -0
  195. package/.cache/typescript/5.4/node_modules/undici-types/balanced-pool.d.ts +18 -0
  196. package/.cache/typescript/5.4/node_modules/undici-types/cache.d.ts +36 -0
  197. package/.cache/typescript/5.4/node_modules/undici-types/client.d.ts +97 -0
  198. package/.cache/typescript/5.4/node_modules/undici-types/connector.d.ts +34 -0
  199. package/.cache/typescript/5.4/node_modules/undici-types/content-type.d.ts +21 -0
  200. package/.cache/typescript/5.4/node_modules/undici-types/cookies.d.ts +28 -0
  201. package/.cache/typescript/5.4/node_modules/undici-types/diagnostics-channel.d.ts +67 -0
  202. package/.cache/typescript/5.4/node_modules/undici-types/dispatcher.d.ts +241 -0
  203. package/.cache/typescript/5.4/node_modules/undici-types/errors.d.ts +128 -0
  204. package/.cache/typescript/5.4/node_modules/undici-types/fetch.d.ts +209 -0
  205. package/.cache/typescript/5.4/node_modules/undici-types/file.d.ts +39 -0
  206. package/.cache/typescript/5.4/node_modules/undici-types/filereader.d.ts +54 -0
  207. package/.cache/typescript/5.4/node_modules/undici-types/formdata.d.ts +108 -0
  208. package/.cache/typescript/5.4/node_modules/undici-types/global-dispatcher.d.ts +9 -0
  209. package/.cache/typescript/5.4/node_modules/undici-types/global-origin.d.ts +7 -0
  210. package/.cache/typescript/5.4/node_modules/undici-types/handlers.d.ts +9 -0
  211. package/.cache/typescript/5.4/node_modules/undici-types/header.d.ts +4 -0
  212. package/.cache/typescript/5.4/node_modules/undici-types/index.d.ts +63 -0
  213. package/.cache/typescript/5.4/node_modules/undici-types/interceptors.d.ts +5 -0
  214. package/.cache/typescript/5.4/node_modules/undici-types/mock-agent.d.ts +50 -0
  215. package/.cache/typescript/5.4/node_modules/undici-types/mock-client.d.ts +25 -0
  216. package/.cache/typescript/5.4/node_modules/undici-types/mock-errors.d.ts +12 -0
  217. package/.cache/typescript/5.4/node_modules/undici-types/mock-interceptor.d.ts +93 -0
  218. package/.cache/typescript/5.4/node_modules/undici-types/mock-pool.d.ts +25 -0
  219. package/.cache/typescript/5.4/node_modules/undici-types/package.json +55 -0
  220. package/.cache/typescript/5.4/node_modules/undici-types/patch.d.ts +71 -0
  221. package/.cache/typescript/5.4/node_modules/undici-types/pool-stats.d.ts +19 -0
  222. package/.cache/typescript/5.4/node_modules/undici-types/pool.d.ts +28 -0
  223. package/.cache/typescript/5.4/node_modules/undici-types/proxy-agent.d.ts +30 -0
  224. package/.cache/typescript/5.4/node_modules/undici-types/readable.d.ts +61 -0
  225. package/.cache/typescript/5.4/node_modules/undici-types/webidl.d.ts +220 -0
  226. package/.cache/typescript/5.4/node_modules/undici-types/websocket.d.ts +131 -0
  227. package/.cache/typescript/5.4/package-lock.json +197 -0
  228. package/.cache/typescript/5.4/package.json +1 -0
  229. package/index.js +1 -1
  230. package/package.json +8 -2
  231. package/.cache/replit/modules/nodejs-20:v36-20240502-f4453db.res +0 -1
  232. package/.cache/replit/modules/replit:v9-20240429-0325cbb.res +0 -1
@@ -0,0 +1,141 @@
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.dataSize = 0
112
+
113
+ The amount of data buffered so far.
114
+
115
+ ### delayedStream.readable
116
+
117
+ An ECMA5 getter that returns the value of `source.readable`.
118
+
119
+ ### delayedStream.resume()
120
+
121
+ If the `delayedStream` has not been released so far, `delayedStream.release()`
122
+ is called.
123
+
124
+ In either case, `source.resume()` is called.
125
+
126
+ ### delayedStream.pause()
127
+
128
+ Calls `source.pause()`.
129
+
130
+ ### delayedStream.pipe(dest)
131
+
132
+ Calls `delayedStream.resume()` and then proxies the arguments to `source.pipe`.
133
+
134
+ ### delayedStream.release()
135
+
136
+ Emits and clears all events that have been buffered up so far. This does not
137
+ resume the underlaying source, use `delayedStream.resume()` instead.
138
+
139
+ ## License
140
+
141
+ delayed-stream is licensed under the MIT license.
@@ -0,0 +1,107 @@
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
+ Object.defineProperty(DelayedStream.prototype, 'readable', {
42
+ configurable: true,
43
+ enumerable: true,
44
+ get: function() {
45
+ return this.source.readable;
46
+ }
47
+ });
48
+
49
+ DelayedStream.prototype.setEncoding = function() {
50
+ return this.source.setEncoding.apply(this.source, arguments);
51
+ };
52
+
53
+ DelayedStream.prototype.resume = function() {
54
+ if (!this._released) {
55
+ this.release();
56
+ }
57
+
58
+ this.source.resume();
59
+ };
60
+
61
+ DelayedStream.prototype.pause = function() {
62
+ this.source.pause();
63
+ };
64
+
65
+ DelayedStream.prototype.release = function() {
66
+ this._released = true;
67
+
68
+ this._bufferedEvents.forEach(function(args) {
69
+ this.emit.apply(this, args);
70
+ }.bind(this));
71
+ this._bufferedEvents = [];
72
+ };
73
+
74
+ DelayedStream.prototype.pipe = function() {
75
+ var r = Stream.prototype.pipe.apply(this, arguments);
76
+ this.resume();
77
+ return r;
78
+ };
79
+
80
+ DelayedStream.prototype._handleEmit = function(args) {
81
+ if (this._released) {
82
+ this.emit.apply(this, args);
83
+ return;
84
+ }
85
+
86
+ if (args[0] === 'data') {
87
+ this.dataSize += args[1].length;
88
+ this._checkIfMaxDataSizeExceeded();
89
+ }
90
+
91
+ this._bufferedEvents.push(args);
92
+ };
93
+
94
+ DelayedStream.prototype._checkIfMaxDataSizeExceeded = function() {
95
+ if (this._maxDataSizeExceeded) {
96
+ return;
97
+ }
98
+
99
+ if (this.dataSize <= this.maxDataSize) {
100
+ return;
101
+ }
102
+
103
+ this._maxDataSizeExceeded = true;
104
+ var message =
105
+ 'DelayedStream#maxDataSize of ' + this.maxDataSize + ' bytes exceeded.'
106
+ this.emit('error', new Error(message));
107
+ };
@@ -0,0 +1,27 @@
1
+ {
2
+ "author": "Felix Geisendörfer <felix@debuggable.com> (http://debuggable.com/)",
3
+ "contributors": [
4
+ "Mike Atkins <apeherder@gmail.com>"
5
+ ],
6
+ "name": "delayed-stream",
7
+ "description": "Buffers events from a stream until you are ready to handle them.",
8
+ "license": "MIT",
9
+ "version": "1.0.0",
10
+ "homepage": "https://github.com/felixge/node-delayed-stream",
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "git://github.com/felixge/node-delayed-stream.git"
14
+ },
15
+ "main": "./lib/delayed_stream",
16
+ "engines": {
17
+ "node": ">=0.4.0"
18
+ },
19
+ "scripts": {
20
+ "test": "make test"
21
+ },
22
+ "dependencies": {},
23
+ "devDependencies": {
24
+ "fake": "0.2.0",
25
+ "far": "0.0.1"
26
+ }
27
+ }
@@ -0,0 +1,11 @@
1
+ Copyright (c) Felix Böhm
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
5
+
6
+ Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7
+
8
+ Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
9
+
10
+ THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS,
11
+ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,15 @@
1
+ //Types of elements found in the DOM
2
+ module.exports = {
3
+ Text: "text", //Text
4
+ Directive: "directive", //<? ... ?>
5
+ Comment: "comment", //<!-- ... -->
6
+ Script: "script", //<script> tags
7
+ Style: "style", //<style> tags
8
+ Tag: "tag", //Any tag
9
+ CDATA: "cdata", //<![CDATA[ ... ]]>
10
+ Doctype: "doctype",
11
+
12
+ isTag: function(elem){
13
+ return elem.type === "tag" || elem.type === "script" || elem.type === "style";
14
+ }
15
+ };
@@ -0,0 +1,16 @@
1
+ {
2
+ "name": "domelementtype",
3
+ "version": "1.3.1",
4
+ "description": "all the types of nodes in htmlparser2's dom",
5
+ "main": "index.js",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git://github.com/fb55/domelementtype.git"
9
+ },
10
+ "keywords": [
11
+ "dom",
12
+ "htmlparser2"
13
+ ],
14
+ "author": "Felix Boehm <me@feedic.com>",
15
+ "license": "BSD-2-Clause"
16
+ }
@@ -0,0 +1 @@
1
+ all the types of nodes in htmlparser2's dom
@@ -0,0 +1,6 @@
1
+ before_install:
2
+ - '[ "${TRAVIS_NODE_VERSION}" != "0.8" ] || npm install -g npm@1.4.28'
3
+ - npm install -g npm@latest
4
+ language: node_js
5
+ node_js:
6
+ - 8
@@ -0,0 +1,11 @@
1
+ Copyright (c) Felix Böhm
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
5
+
6
+ Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7
+
8
+ Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
9
+
10
+ THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS,
11
+ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,217 @@
1
+ var ElementType = require("domelementtype");
2
+
3
+ var re_whitespace = /\s+/g;
4
+ var NodePrototype = require("./lib/node");
5
+ var ElementPrototype = require("./lib/element");
6
+
7
+ function DomHandler(callback, options, elementCB){
8
+ if(typeof callback === "object"){
9
+ elementCB = options;
10
+ options = callback;
11
+ callback = null;
12
+ } else if(typeof options === "function"){
13
+ elementCB = options;
14
+ options = defaultOpts;
15
+ }
16
+ this._callback = callback;
17
+ this._options = options || defaultOpts;
18
+ this._elementCB = elementCB;
19
+ this.dom = [];
20
+ this._done = false;
21
+ this._tagStack = [];
22
+ this._parser = this._parser || null;
23
+ }
24
+
25
+ //default options
26
+ var defaultOpts = {
27
+ normalizeWhitespace: false, //Replace all whitespace with single spaces
28
+ withStartIndices: false, //Add startIndex properties to nodes
29
+ withEndIndices: false, //Add endIndex properties to nodes
30
+ };
31
+
32
+ DomHandler.prototype.onparserinit = function(parser){
33
+ this._parser = parser;
34
+ };
35
+
36
+ //Resets the handler back to starting state
37
+ DomHandler.prototype.onreset = function(){
38
+ DomHandler.call(this, this._callback, this._options, this._elementCB);
39
+ };
40
+
41
+ //Signals the handler that parsing is done
42
+ DomHandler.prototype.onend = function(){
43
+ if(this._done) return;
44
+ this._done = true;
45
+ this._parser = null;
46
+ this._handleCallback(null);
47
+ };
48
+
49
+ DomHandler.prototype._handleCallback =
50
+ DomHandler.prototype.onerror = function(error){
51
+ if(typeof this._callback === "function"){
52
+ this._callback(error, this.dom);
53
+ } else {
54
+ if(error) throw error;
55
+ }
56
+ };
57
+
58
+ DomHandler.prototype.onclosetag = function(){
59
+ //if(this._tagStack.pop().name !== name) this._handleCallback(Error("Tagname didn't match!"));
60
+
61
+ var elem = this._tagStack.pop();
62
+
63
+ if(this._options.withEndIndices && elem){
64
+ elem.endIndex = this._parser.endIndex;
65
+ }
66
+
67
+ if(this._elementCB) this._elementCB(elem);
68
+ };
69
+
70
+ DomHandler.prototype._createDomElement = function(properties){
71
+ if (!this._options.withDomLvl1) return properties;
72
+
73
+ var element;
74
+ if (properties.type === "tag") {
75
+ element = Object.create(ElementPrototype);
76
+ } else {
77
+ element = Object.create(NodePrototype);
78
+ }
79
+
80
+ for (var key in properties) {
81
+ if (properties.hasOwnProperty(key)) {
82
+ element[key] = properties[key];
83
+ }
84
+ }
85
+
86
+ return element;
87
+ };
88
+
89
+ DomHandler.prototype._addDomElement = function(element){
90
+ var parent = this._tagStack[this._tagStack.length - 1];
91
+ var siblings = parent ? parent.children : this.dom;
92
+ var previousSibling = siblings[siblings.length - 1];
93
+
94
+ element.next = null;
95
+
96
+ if(this._options.withStartIndices){
97
+ element.startIndex = this._parser.startIndex;
98
+ }
99
+ if(this._options.withEndIndices){
100
+ element.endIndex = this._parser.endIndex;
101
+ }
102
+
103
+ if(previousSibling){
104
+ element.prev = previousSibling;
105
+ previousSibling.next = element;
106
+ } else {
107
+ element.prev = null;
108
+ }
109
+
110
+ siblings.push(element);
111
+ element.parent = parent || null;
112
+ };
113
+
114
+ DomHandler.prototype.onopentag = function(name, attribs){
115
+ var properties = {
116
+ type: name === "script" ? ElementType.Script : name === "style" ? ElementType.Style : ElementType.Tag,
117
+ name: name,
118
+ attribs: attribs,
119
+ children: []
120
+ };
121
+
122
+ var element = this._createDomElement(properties);
123
+
124
+ this._addDomElement(element);
125
+
126
+ this._tagStack.push(element);
127
+ };
128
+
129
+ DomHandler.prototype.ontext = function(data){
130
+ //the ignoreWhitespace is officially dropped, but for now,
131
+ //it's an alias for normalizeWhitespace
132
+ var normalize = this._options.normalizeWhitespace || this._options.ignoreWhitespace;
133
+
134
+ var lastTag;
135
+
136
+ if(!this._tagStack.length && this.dom.length && (lastTag = this.dom[this.dom.length-1]).type === ElementType.Text){
137
+ if(normalize){
138
+ lastTag.data = (lastTag.data + data).replace(re_whitespace, " ");
139
+ } else {
140
+ lastTag.data += data;
141
+ }
142
+ } else {
143
+ if(
144
+ this._tagStack.length &&
145
+ (lastTag = this._tagStack[this._tagStack.length - 1]) &&
146
+ (lastTag = lastTag.children[lastTag.children.length - 1]) &&
147
+ lastTag.type === ElementType.Text
148
+ ){
149
+ if(normalize){
150
+ lastTag.data = (lastTag.data + data).replace(re_whitespace, " ");
151
+ } else {
152
+ lastTag.data += data;
153
+ }
154
+ } else {
155
+ if(normalize){
156
+ data = data.replace(re_whitespace, " ");
157
+ }
158
+
159
+ var element = this._createDomElement({
160
+ data: data,
161
+ type: ElementType.Text
162
+ });
163
+
164
+ this._addDomElement(element);
165
+ }
166
+ }
167
+ };
168
+
169
+ DomHandler.prototype.oncomment = function(data){
170
+ var lastTag = this._tagStack[this._tagStack.length - 1];
171
+
172
+ if(lastTag && lastTag.type === ElementType.Comment){
173
+ lastTag.data += data;
174
+ return;
175
+ }
176
+
177
+ var properties = {
178
+ data: data,
179
+ type: ElementType.Comment
180
+ };
181
+
182
+ var element = this._createDomElement(properties);
183
+
184
+ this._addDomElement(element);
185
+ this._tagStack.push(element);
186
+ };
187
+
188
+ DomHandler.prototype.oncdatastart = function(){
189
+ var properties = {
190
+ children: [{
191
+ data: "",
192
+ type: ElementType.Text
193
+ }],
194
+ type: ElementType.CDATA
195
+ };
196
+
197
+ var element = this._createDomElement(properties);
198
+
199
+ this._addDomElement(element);
200
+ this._tagStack.push(element);
201
+ };
202
+
203
+ DomHandler.prototype.oncommentend = DomHandler.prototype.oncdataend = function(){
204
+ this._tagStack.pop();
205
+ };
206
+
207
+ DomHandler.prototype.onprocessinginstruction = function(name, data){
208
+ var element = this._createDomElement({
209
+ name: name,
210
+ data: data,
211
+ type: ElementType.Directive
212
+ });
213
+
214
+ this._addDomElement(element);
215
+ };
216
+
217
+ module.exports = DomHandler;
@@ -0,0 +1,20 @@
1
+ // DOM-Level-1-compliant structure
2
+ var NodePrototype = require('./node');
3
+ var ElementPrototype = module.exports = Object.create(NodePrototype);
4
+
5
+ var domLvl1 = {
6
+ tagName: "name"
7
+ };
8
+
9
+ Object.keys(domLvl1).forEach(function(key) {
10
+ var shorthand = domLvl1[key];
11
+ Object.defineProperty(ElementPrototype, key, {
12
+ get: function() {
13
+ return this[shorthand] || null;
14
+ },
15
+ set: function(val) {
16
+ this[shorthand] = val;
17
+ return val;
18
+ }
19
+ });
20
+ });
@@ -0,0 +1,44 @@
1
+ // This object will be used as the prototype for Nodes when creating a
2
+ // DOM-Level-1-compliant structure.
3
+ var NodePrototype = module.exports = {
4
+ get firstChild() {
5
+ var children = this.children;
6
+ return children && children[0] || null;
7
+ },
8
+ get lastChild() {
9
+ var children = this.children;
10
+ return children && children[children.length - 1] || null;
11
+ },
12
+ get nodeType() {
13
+ return nodeTypes[this.type] || nodeTypes.element;
14
+ }
15
+ };
16
+
17
+ var domLvl1 = {
18
+ tagName: "name",
19
+ childNodes: "children",
20
+ parentNode: "parent",
21
+ previousSibling: "prev",
22
+ nextSibling: "next",
23
+ nodeValue: "data"
24
+ };
25
+
26
+ var nodeTypes = {
27
+ element: 1,
28
+ text: 3,
29
+ cdata: 4,
30
+ comment: 8
31
+ };
32
+
33
+ Object.keys(domLvl1).forEach(function(key) {
34
+ var shorthand = domLvl1[key];
35
+ Object.defineProperty(NodePrototype, key, {
36
+ get: function() {
37
+ return this[shorthand] || null;
38
+ },
39
+ set: function(val) {
40
+ this[shorthand] = val;
41
+ return val;
42
+ }
43
+ });
44
+ });
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "domhandler",
3
+ "version": "2.4.2",
4
+ "description": "handler for htmlparser2 that turns pages into a dom",
5
+ "main": "index.js",
6
+ "directories": {
7
+ "test": "tests"
8
+ },
9
+ "scripts": {
10
+ "test": "mocha -R list && jshint index.js test/"
11
+ },
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git://github.com/fb55/DomHandler.git"
15
+ },
16
+ "keywords": [
17
+ "dom",
18
+ "htmlparser2"
19
+ ],
20
+ "dependencies": {
21
+ "domelementtype": "1"
22
+ },
23
+ "devDependencies": {
24
+ "htmlparser2": "^3.9.0",
25
+ "mocha": "^3.0.2",
26
+ "jshint": "^2.9.1"
27
+ },
28
+ "author": "Felix Boehm <me@feedic.com>",
29
+ "license": "BSD-2-Clause",
30
+ "jshintConfig": {
31
+ "quotmark": "double",
32
+ "trailing": true,
33
+ "unused": true,
34
+ "undef": true,
35
+ "node": true,
36
+ "proto": true,
37
+ "globals": {
38
+ "it": true
39
+ }
40
+ }
41
+ }