postdoc 0.2.0.beta4 → 0.2.4

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 (370) hide show
  1. checksums.yaml +4 -4
  2. data/lib/postdoc.rb +50 -18
  3. metadata +24 -378
  4. data/lib/pdf.js +0 -27
  5. data/node_modules/agent-base/History.md +0 -113
  6. data/node_modules/agent-base/README.md +0 -145
  7. data/node_modules/agent-base/index.js +0 -160
  8. data/node_modules/agent-base/package.json +0 -35
  9. data/node_modules/agent-base/patch-core.js +0 -37
  10. data/node_modules/agent-base/test/ssl-cert-snakeoil.key +0 -15
  11. data/node_modules/agent-base/test/ssl-cert-snakeoil.pem +0 -12
  12. data/node_modules/agent-base/test/test.js +0 -673
  13. data/node_modules/async-limiter/LICENSE +0 -8
  14. data/node_modules/async-limiter/coverage/coverage.json +0 -1
  15. data/node_modules/async-limiter/coverage/lcov-report/async-throttle/index.html +0 -73
  16. data/node_modules/async-limiter/coverage/lcov-report/async-throttle/index.js.html +0 -246
  17. data/node_modules/async-limiter/coverage/lcov-report/base.css +0 -182
  18. data/node_modules/async-limiter/coverage/lcov-report/index.html +0 -73
  19. data/node_modules/async-limiter/coverage/lcov-report/prettify.css +0 -1
  20. data/node_modules/async-limiter/coverage/lcov-report/prettify.js +0 -1
  21. data/node_modules/async-limiter/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  22. data/node_modules/async-limiter/coverage/lcov-report/sorter.js +0 -156
  23. data/node_modules/async-limiter/coverage/lcov.info +0 -74
  24. data/node_modules/async-limiter/index.js +0 -67
  25. data/node_modules/async-limiter/package.json +0 -35
  26. data/node_modules/async-limiter/readme.md +0 -132
  27. data/node_modules/balanced-match/LICENSE.md +0 -21
  28. data/node_modules/balanced-match/README.md +0 -91
  29. data/node_modules/balanced-match/index.js +0 -59
  30. data/node_modules/balanced-match/package.json +0 -49
  31. data/node_modules/brace-expansion/LICENSE +0 -21
  32. data/node_modules/brace-expansion/README.md +0 -129
  33. data/node_modules/brace-expansion/index.js +0 -201
  34. data/node_modules/brace-expansion/package.json +0 -47
  35. data/node_modules/buffer-from/index.js +0 -69
  36. data/node_modules/buffer-from/package.json +0 -16
  37. data/node_modules/buffer-from/readme.md +0 -69
  38. data/node_modules/buffer-from/test.js +0 -12
  39. data/node_modules/concat-map/LICENSE +0 -18
  40. data/node_modules/concat-map/README.markdown +0 -62
  41. data/node_modules/concat-map/example/map.js +0 -6
  42. data/node_modules/concat-map/index.js +0 -13
  43. data/node_modules/concat-map/package.json +0 -43
  44. data/node_modules/concat-map/test/map.js +0 -39
  45. data/node_modules/concat-stream/LICENSE +0 -24
  46. data/node_modules/concat-stream/index.js +0 -144
  47. data/node_modules/concat-stream/package.json +0 -55
  48. data/node_modules/concat-stream/readme.md +0 -102
  49. data/node_modules/core-util-is/LICENSE +0 -19
  50. data/node_modules/core-util-is/README.md +0 -3
  51. data/node_modules/core-util-is/float.patch +0 -604
  52. data/node_modules/core-util-is/lib/util.js +0 -107
  53. data/node_modules/core-util-is/package.json +0 -32
  54. data/node_modules/core-util-is/test.js +0 -68
  55. data/node_modules/debug/CHANGELOG.md +0 -395
  56. data/node_modules/debug/LICENSE +0 -19
  57. data/node_modules/debug/Makefile +0 -58
  58. data/node_modules/debug/README.md +0 -368
  59. data/node_modules/debug/karma.conf.js +0 -70
  60. data/node_modules/debug/node.js +0 -1
  61. data/node_modules/debug/package.json +0 -43
  62. data/node_modules/debug/src/browser.js +0 -195
  63. data/node_modules/debug/src/debug.js +0 -225
  64. data/node_modules/debug/src/index.js +0 -10
  65. data/node_modules/debug/src/node.js +0 -186
  66. data/node_modules/es6-promise/CHANGELOG.md +0 -151
  67. data/node_modules/es6-promise/LICENSE +0 -19
  68. data/node_modules/es6-promise/README.md +0 -97
  69. data/node_modules/es6-promise/auto.js +0 -4
  70. data/node_modules/es6-promise/dist/es6-promise.auto.js +0 -1181
  71. data/node_modules/es6-promise/dist/es6-promise.auto.map +0 -1
  72. data/node_modules/es6-promise/dist/es6-promise.auto.min.js +0 -1
  73. data/node_modules/es6-promise/dist/es6-promise.auto.min.map +0 -1
  74. data/node_modules/es6-promise/dist/es6-promise.js +0 -1179
  75. data/node_modules/es6-promise/dist/es6-promise.map +0 -1
  76. data/node_modules/es6-promise/dist/es6-promise.min.js +0 -1
  77. data/node_modules/es6-promise/dist/es6-promise.min.map +0 -1
  78. data/node_modules/es6-promise/es6-promise.d.ts +0 -81
  79. data/node_modules/es6-promise/lib/es6-promise.auto.js +0 -3
  80. data/node_modules/es6-promise/lib/es6-promise.js +0 -7
  81. data/node_modules/es6-promise/lib/es6-promise/-internal.js +0 -266
  82. data/node_modules/es6-promise/lib/es6-promise/asap.js +0 -119
  83. data/node_modules/es6-promise/lib/es6-promise/enumerator.js +0 -113
  84. data/node_modules/es6-promise/lib/es6-promise/polyfill.js +0 -35
  85. data/node_modules/es6-promise/lib/es6-promise/promise.js +0 -427
  86. data/node_modules/es6-promise/lib/es6-promise/promise/all.js +0 -52
  87. data/node_modules/es6-promise/lib/es6-promise/promise/race.js +0 -84
  88. data/node_modules/es6-promise/lib/es6-promise/promise/reject.js +0 -46
  89. data/node_modules/es6-promise/lib/es6-promise/promise/resolve.js +0 -48
  90. data/node_modules/es6-promise/lib/es6-promise/then.js +0 -32
  91. data/node_modules/es6-promise/lib/es6-promise/utils.js +0 -21
  92. data/node_modules/es6-promise/package.json +0 -75
  93. data/node_modules/es6-promisify/README.md +0 -89
  94. data/node_modules/es6-promisify/dist/promise.js +0 -73
  95. data/node_modules/es6-promisify/dist/promisify.js +0 -85
  96. data/node_modules/es6-promisify/package.json +0 -41
  97. data/node_modules/extract-zip/CONTRIBUTING.md +0 -1
  98. data/node_modules/extract-zip/LICENSE +0 -23
  99. data/node_modules/extract-zip/cli.js +0 -20
  100. data/node_modules/extract-zip/index.js +0 -205
  101. data/node_modules/extract-zip/node_modules/debug/CHANGELOG.md +0 -362
  102. data/node_modules/extract-zip/node_modules/debug/LICENSE +0 -19
  103. data/node_modules/extract-zip/node_modules/debug/Makefile +0 -50
  104. data/node_modules/extract-zip/node_modules/debug/README.md +0 -312
  105. data/node_modules/extract-zip/node_modules/debug/component.json +0 -19
  106. data/node_modules/extract-zip/node_modules/debug/karma.conf.js +0 -70
  107. data/node_modules/extract-zip/node_modules/debug/node.js +0 -1
  108. data/node_modules/extract-zip/node_modules/debug/package.json +0 -49
  109. data/node_modules/extract-zip/node_modules/debug/src/browser.js +0 -185
  110. data/node_modules/extract-zip/node_modules/debug/src/debug.js +0 -202
  111. data/node_modules/extract-zip/node_modules/debug/src/index.js +0 -10
  112. data/node_modules/extract-zip/node_modules/debug/src/inspector-log.js +0 -15
  113. data/node_modules/extract-zip/node_modules/debug/src/node.js +0 -248
  114. data/node_modules/extract-zip/package.json +0 -35
  115. data/node_modules/extract-zip/readme.md +0 -49
  116. data/node_modules/fd-slicer/CHANGELOG.md +0 -49
  117. data/node_modules/fd-slicer/LICENSE +0 -21
  118. data/node_modules/fd-slicer/README.md +0 -189
  119. data/node_modules/fd-slicer/index.js +0 -277
  120. data/node_modules/fd-slicer/package.json +0 -36
  121. data/node_modules/fd-slicer/test/test.js +0 -350
  122. data/node_modules/fs.realpath/LICENSE +0 -43
  123. data/node_modules/fs.realpath/README.md +0 -33
  124. data/node_modules/fs.realpath/index.js +0 -66
  125. data/node_modules/fs.realpath/old.js +0 -303
  126. data/node_modules/fs.realpath/package.json +0 -26
  127. data/node_modules/glob/LICENSE +0 -15
  128. data/node_modules/glob/README.md +0 -368
  129. data/node_modules/glob/changelog.md +0 -67
  130. data/node_modules/glob/common.js +0 -240
  131. data/node_modules/glob/glob.js +0 -790
  132. data/node_modules/glob/package.json +0 -43
  133. data/node_modules/glob/sync.js +0 -486
  134. data/node_modules/https-proxy-agent/History.md +0 -124
  135. data/node_modules/https-proxy-agent/README.md +0 -137
  136. data/node_modules/https-proxy-agent/index.js +0 -229
  137. data/node_modules/https-proxy-agent/package.json +0 -35
  138. data/node_modules/https-proxy-agent/test/ssl-cert-snakeoil.key +0 -15
  139. data/node_modules/https-proxy-agent/test/ssl-cert-snakeoil.pem +0 -12
  140. data/node_modules/https-proxy-agent/test/test.js +0 -342
  141. data/node_modules/inflight/LICENSE +0 -15
  142. data/node_modules/inflight/README.md +0 -37
  143. data/node_modules/inflight/inflight.js +0 -54
  144. data/node_modules/inflight/package.json +0 -29
  145. data/node_modules/inherits/LICENSE +0 -16
  146. data/node_modules/inherits/README.md +0 -42
  147. data/node_modules/inherits/inherits.js +0 -7
  148. data/node_modules/inherits/inherits_browser.js +0 -23
  149. data/node_modules/inherits/package.json +0 -29
  150. data/node_modules/isarray/Makefile +0 -6
  151. data/node_modules/isarray/README.md +0 -60
  152. data/node_modules/isarray/component.json +0 -19
  153. data/node_modules/isarray/index.js +0 -5
  154. data/node_modules/isarray/package.json +0 -45
  155. data/node_modules/isarray/test.js +0 -20
  156. data/node_modules/mime/CHANGELOG.md +0 -225
  157. data/node_modules/mime/CONTRIBUTING.md +0 -5
  158. data/node_modules/mime/LICENSE +0 -21
  159. data/node_modules/mime/Mime.js +0 -89
  160. data/node_modules/mime/README.md +0 -188
  161. data/node_modules/mime/cli.js +0 -10
  162. data/node_modules/mime/index.js +0 -4
  163. data/node_modules/mime/lite.js +0 -4
  164. data/node_modules/mime/package.json +0 -43
  165. data/node_modules/mime/src/README_js.md +0 -179
  166. data/node_modules/mime/src/build.js +0 -71
  167. data/node_modules/mime/src/test.js +0 -257
  168. data/node_modules/mime/types/other.json +0 -1
  169. data/node_modules/mime/types/standard.json +0 -1
  170. data/node_modules/minimatch/LICENSE +0 -15
  171. data/node_modules/minimatch/README.md +0 -209
  172. data/node_modules/minimatch/minimatch.js +0 -923
  173. data/node_modules/minimatch/package.json +0 -30
  174. data/node_modules/minimist/LICENSE +0 -18
  175. data/node_modules/minimist/example/parse.js +0 -2
  176. data/node_modules/minimist/index.js +0 -187
  177. data/node_modules/minimist/package.json +0 -40
  178. data/node_modules/minimist/readme.markdown +0 -73
  179. data/node_modules/minimist/test/dash.js +0 -24
  180. data/node_modules/minimist/test/default_bool.js +0 -20
  181. data/node_modules/minimist/test/dotted.js +0 -16
  182. data/node_modules/minimist/test/long.js +0 -31
  183. data/node_modules/minimist/test/parse.js +0 -318
  184. data/node_modules/minimist/test/parse_modified.js +0 -9
  185. data/node_modules/minimist/test/short.js +0 -67
  186. data/node_modules/minimist/test/whitespace.js +0 -8
  187. data/node_modules/mkdirp/LICENSE +0 -21
  188. data/node_modules/mkdirp/bin/cmd.js +0 -33
  189. data/node_modules/mkdirp/bin/usage.txt +0 -12
  190. data/node_modules/mkdirp/examples/pow.js +0 -6
  191. data/node_modules/mkdirp/index.js +0 -98
  192. data/node_modules/mkdirp/package.json +0 -27
  193. data/node_modules/mkdirp/readme.markdown +0 -100
  194. data/node_modules/mkdirp/test/chmod.js +0 -41
  195. data/node_modules/mkdirp/test/clobber.js +0 -38
  196. data/node_modules/mkdirp/test/mkdirp.js +0 -28
  197. data/node_modules/mkdirp/test/opts_fs.js +0 -29
  198. data/node_modules/mkdirp/test/opts_fs_sync.js +0 -27
  199. data/node_modules/mkdirp/test/perm.js +0 -32
  200. data/node_modules/mkdirp/test/perm_sync.js +0 -36
  201. data/node_modules/mkdirp/test/race.js +0 -37
  202. data/node_modules/mkdirp/test/rel.js +0 -32
  203. data/node_modules/mkdirp/test/return.js +0 -25
  204. data/node_modules/mkdirp/test/return_sync.js +0 -24
  205. data/node_modules/mkdirp/test/root.js +0 -19
  206. data/node_modules/mkdirp/test/sync.js +0 -32
  207. data/node_modules/mkdirp/test/umask.js +0 -28
  208. data/node_modules/mkdirp/test/umask_sync.js +0 -32
  209. data/node_modules/ms/index.js +0 -152
  210. data/node_modules/ms/license.md +0 -21
  211. data/node_modules/ms/package.json +0 -37
  212. data/node_modules/ms/readme.md +0 -51
  213. data/node_modules/once/LICENSE +0 -15
  214. data/node_modules/once/README.md +0 -79
  215. data/node_modules/once/once.js +0 -42
  216. data/node_modules/once/package.json +0 -33
  217. data/node_modules/path-is-absolute/index.js +0 -20
  218. data/node_modules/path-is-absolute/license +0 -21
  219. data/node_modules/path-is-absolute/package.json +0 -43
  220. data/node_modules/path-is-absolute/readme.md +0 -59
  221. data/node_modules/pend/LICENSE +0 -23
  222. data/node_modules/pend/README.md +0 -41
  223. data/node_modules/pend/index.js +0 -55
  224. data/node_modules/pend/package.json +0 -18
  225. data/node_modules/pend/test.js +0 -137
  226. data/node_modules/process-nextick-args/index.js +0 -44
  227. data/node_modules/process-nextick-args/license.md +0 -19
  228. data/node_modules/process-nextick-args/package.json +0 -25
  229. data/node_modules/process-nextick-args/readme.md +0 -18
  230. data/node_modules/progress/CHANGELOG.md +0 -115
  231. data/node_modules/progress/LICENSE +0 -22
  232. data/node_modules/progress/Makefile +0 -8
  233. data/node_modules/progress/README.md +0 -146
  234. data/node_modules/progress/index.js +0 -1
  235. data/node_modules/progress/lib/node-progress.js +0 -231
  236. data/node_modules/progress/package.json +0 -25
  237. data/node_modules/proxy-from-env/README.md +0 -131
  238. data/node_modules/proxy-from-env/index.js +0 -103
  239. data/node_modules/proxy-from-env/package.json +0 -35
  240. data/node_modules/proxy-from-env/test.js +0 -393
  241. data/node_modules/puppeteer/CONTRIBUTING.md +0 -206
  242. data/node_modules/puppeteer/DeviceDescriptors.js +0 -704
  243. data/node_modules/puppeteer/LICENSE +0 -202
  244. data/node_modules/puppeteer/README.md +0 -306
  245. data/node_modules/puppeteer/index.js +0 -28
  246. data/node_modules/puppeteer/install.js +0 -122
  247. data/node_modules/puppeteer/lib/Browser.js +0 -186
  248. data/node_modules/puppeteer/lib/BrowserFetcher.js +0 -279
  249. data/node_modules/puppeteer/lib/Connection.js +0 -246
  250. data/node_modules/puppeteer/lib/Coverage.js +0 -301
  251. data/node_modules/puppeteer/lib/Dialog.js +0 -84
  252. data/node_modules/puppeteer/lib/ElementHandle.js +0 -328
  253. data/node_modules/puppeteer/lib/EmulationManager.js +0 -89
  254. data/node_modules/puppeteer/lib/ExecutionContext.js +0 -232
  255. data/node_modules/puppeteer/lib/FrameManager.js +0 -997
  256. data/node_modules/puppeteer/lib/Input.js +0 -309
  257. data/node_modules/puppeteer/lib/Launcher.js +0 -310
  258. data/node_modules/puppeteer/lib/Multimap.js +0 -95
  259. data/node_modules/puppeteer/lib/NavigatorWatcher.js +0 -137
  260. data/node_modules/puppeteer/lib/NetworkManager.js +0 -796
  261. data/node_modules/puppeteer/lib/Page.js +0 -1098
  262. data/node_modules/puppeteer/lib/Pipe.js +0 -69
  263. data/node_modules/puppeteer/lib/Puppeteer.js +0 -60
  264. data/node_modules/puppeteer/lib/Target.js +0 -88
  265. data/node_modules/puppeteer/lib/TaskQueue.js +0 -17
  266. data/node_modules/puppeteer/lib/Tracing.js +0 -99
  267. data/node_modules/puppeteer/lib/USKeyboardLayout.js +0 -281
  268. data/node_modules/puppeteer/lib/helper.js +0 -248
  269. data/node_modules/puppeteer/node6/lib/Browser.js +0 -394
  270. data/node_modules/puppeteer/node6/lib/BrowserFetcher.js +0 -357
  271. data/node_modules/puppeteer/node6/lib/Connection.js +0 -350
  272. data/node_modules/puppeteer/node6/lib/Coverage.js +0 -561
  273. data/node_modules/puppeteer/node6/lib/Dialog.js +0 -136
  274. data/node_modules/puppeteer/node6/lib/ElementHandle.js +0 -796
  275. data/node_modules/puppeteer/node6/lib/EmulationManager.js +0 -115
  276. data/node_modules/puppeteer/node6/lib/ExecutionContext.js +0 -414
  277. data/node_modules/puppeteer/node6/lib/FrameManager.js +0 -1621
  278. data/node_modules/puppeteer/node6/lib/Input.js +0 -569
  279. data/node_modules/puppeteer/node6/lib/Launcher.js +0 -362
  280. data/node_modules/puppeteer/node6/lib/Multimap.js +0 -95
  281. data/node_modules/puppeteer/node6/lib/NavigatorWatcher.js +0 -163
  282. data/node_modules/puppeteer/node6/lib/NetworkManager.js +0 -1108
  283. data/node_modules/puppeteer/node6/lib/Page.js +0 -2242
  284. data/node_modules/puppeteer/node6/lib/Pipe.js +0 -69
  285. data/node_modules/puppeteer/node6/lib/Puppeteer.js +0 -60
  286. data/node_modules/puppeteer/node6/lib/Target.js +0 -114
  287. data/node_modules/puppeteer/node6/lib/TaskQueue.js +0 -17
  288. data/node_modules/puppeteer/node6/lib/Tracing.js +0 -177
  289. data/node_modules/puppeteer/node6/lib/USKeyboardLayout.js +0 -281
  290. data/node_modules/puppeteer/node6/lib/helper.js +0 -274
  291. data/node_modules/puppeteer/package.json +0 -61
  292. data/node_modules/readable-stream/CONTRIBUTING.md +0 -38
  293. data/node_modules/readable-stream/GOVERNANCE.md +0 -136
  294. data/node_modules/readable-stream/LICENSE +0 -47
  295. data/node_modules/readable-stream/README.md +0 -58
  296. data/node_modules/readable-stream/doc/wg-meetings/2015-01-30.md +0 -60
  297. data/node_modules/readable-stream/duplex-browser.js +0 -1
  298. data/node_modules/readable-stream/duplex.js +0 -1
  299. data/node_modules/readable-stream/lib/_stream_duplex.js +0 -131
  300. data/node_modules/readable-stream/lib/_stream_passthrough.js +0 -47
  301. data/node_modules/readable-stream/lib/_stream_readable.js +0 -1019
  302. data/node_modules/readable-stream/lib/_stream_transform.js +0 -214
  303. data/node_modules/readable-stream/lib/_stream_writable.js +0 -687
  304. data/node_modules/readable-stream/lib/internal/streams/BufferList.js +0 -79
  305. data/node_modules/readable-stream/lib/internal/streams/destroy.js +0 -74
  306. data/node_modules/readable-stream/lib/internal/streams/stream-browser.js +0 -1
  307. data/node_modules/readable-stream/lib/internal/streams/stream.js +0 -1
  308. data/node_modules/readable-stream/package.json +0 -52
  309. data/node_modules/readable-stream/passthrough.js +0 -1
  310. data/node_modules/readable-stream/readable-browser.js +0 -7
  311. data/node_modules/readable-stream/readable.js +0 -19
  312. data/node_modules/readable-stream/transform.js +0 -1
  313. data/node_modules/readable-stream/writable-browser.js +0 -1
  314. data/node_modules/readable-stream/writable.js +0 -8
  315. data/node_modules/rimraf/LICENSE +0 -15
  316. data/node_modules/rimraf/README.md +0 -101
  317. data/node_modules/rimraf/bin.js +0 -50
  318. data/node_modules/rimraf/package.json +0 -26
  319. data/node_modules/rimraf/rimraf.js +0 -364
  320. data/node_modules/safe-buffer/LICENSE +0 -21
  321. data/node_modules/safe-buffer/README.md +0 -584
  322. data/node_modules/safe-buffer/index.d.ts +0 -187
  323. data/node_modules/safe-buffer/index.js +0 -62
  324. data/node_modules/safe-buffer/package.json +0 -37
  325. data/node_modules/string_decoder/LICENSE +0 -48
  326. data/node_modules/string_decoder/README.md +0 -47
  327. data/node_modules/string_decoder/lib/string_decoder.js +0 -296
  328. data/node_modules/string_decoder/package.json +0 -31
  329. data/node_modules/typedarray/LICENSE +0 -35
  330. data/node_modules/typedarray/example/tarray.js +0 -4
  331. data/node_modules/typedarray/index.js +0 -630
  332. data/node_modules/typedarray/package.json +0 -55
  333. data/node_modules/typedarray/readme.markdown +0 -61
  334. data/node_modules/typedarray/test/server/undef_globals.js +0 -19
  335. data/node_modules/typedarray/test/tarray.js +0 -10
  336. data/node_modules/ultron/LICENSE +0 -22
  337. data/node_modules/ultron/README.md +0 -113
  338. data/node_modules/ultron/index.js +0 -136
  339. data/node_modules/ultron/package.json +0 -41
  340. data/node_modules/util-deprecate/History.md +0 -16
  341. data/node_modules/util-deprecate/LICENSE +0 -24
  342. data/node_modules/util-deprecate/README.md +0 -53
  343. data/node_modules/util-deprecate/browser.js +0 -67
  344. data/node_modules/util-deprecate/node.js +0 -6
  345. data/node_modules/util-deprecate/package.json +0 -27
  346. data/node_modules/wrappy/LICENSE +0 -15
  347. data/node_modules/wrappy/README.md +0 -36
  348. data/node_modules/wrappy/package.json +0 -29
  349. data/node_modules/wrappy/wrappy.js +0 -33
  350. data/node_modules/ws/LICENSE +0 -21
  351. data/node_modules/ws/README.md +0 -341
  352. data/node_modules/ws/index.js +0 -15
  353. data/node_modules/ws/lib/BufferUtil.js +0 -71
  354. data/node_modules/ws/lib/Constants.js +0 -10
  355. data/node_modules/ws/lib/ErrorCodes.js +0 -28
  356. data/node_modules/ws/lib/EventTarget.js +0 -151
  357. data/node_modules/ws/lib/Extensions.js +0 -203
  358. data/node_modules/ws/lib/PerMessageDeflate.js +0 -507
  359. data/node_modules/ws/lib/Receiver.js +0 -553
  360. data/node_modules/ws/lib/Sender.js +0 -412
  361. data/node_modules/ws/lib/Validation.js +0 -17
  362. data/node_modules/ws/lib/WebSocket.js +0 -717
  363. data/node_modules/ws/lib/WebSocketServer.js +0 -326
  364. data/node_modules/ws/package.json +0 -46
  365. data/node_modules/yauzl/LICENSE +0 -21
  366. data/node_modules/yauzl/README.md +0 -467
  367. data/node_modules/yauzl/index.js +0 -626
  368. data/node_modules/yauzl/package.json +0 -36
  369. data/package.json +0 -5
  370. data/yarn.lock +0 -240
@@ -1,626 +0,0 @@
1
- var fs = require("fs");
2
- var zlib = require("zlib");
3
- var fd_slicer = require("fd-slicer");
4
- var util = require("util");
5
- var EventEmitter = require("events").EventEmitter;
6
- var Transform = require("stream").Transform;
7
- var PassThrough = require("stream").PassThrough;
8
- var Writable = require("stream").Writable;
9
-
10
- exports.open = open;
11
- exports.fromFd = fromFd;
12
- exports.fromBuffer = fromBuffer;
13
- exports.fromRandomAccessReader = fromRandomAccessReader;
14
- exports.dosDateTimeToDate = dosDateTimeToDate;
15
- exports.ZipFile = ZipFile;
16
- exports.Entry = Entry;
17
- exports.RandomAccessReader = RandomAccessReader;
18
-
19
- function open(path, options, callback) {
20
- if (typeof options === "function") {
21
- callback = options;
22
- options = null;
23
- }
24
- if (options == null) options = {};
25
- if (options.autoClose == null) options.autoClose = true;
26
- if (options.lazyEntries == null) options.lazyEntries = false;
27
- if (callback == null) callback = defaultCallback;
28
- fs.open(path, "r", function(err, fd) {
29
- if (err) return callback(err);
30
- fromFd(fd, options, function(err, zipfile) {
31
- if (err) fs.close(fd, defaultCallback);
32
- callback(err, zipfile);
33
- });
34
- });
35
- }
36
-
37
- function fromFd(fd, options, callback) {
38
- if (typeof options === "function") {
39
- callback = options;
40
- options = null;
41
- }
42
- if (options == null) options = {};
43
- if (options.autoClose == null) options.autoClose = false;
44
- if (options.lazyEntries == null) options.lazyEntries = false;
45
- if (callback == null) callback = defaultCallback;
46
- fs.fstat(fd, function(err, stats) {
47
- if (err) return callback(err);
48
- var reader = fd_slicer.createFromFd(fd, {autoClose: true});
49
- fromRandomAccessReader(reader, stats.size, options, callback);
50
- });
51
- }
52
-
53
- function fromBuffer(buffer, options, callback) {
54
- if (typeof options === "function") {
55
- callback = options;
56
- options = null;
57
- }
58
- if (options == null) options = {};
59
- options.autoClose = false;
60
- if (options.lazyEntries == null) options.lazyEntries = false;
61
- // i got your open file right here.
62
- var reader = fd_slicer.createFromBuffer(buffer);
63
- fromRandomAccessReader(reader, buffer.length, options, callback);
64
- }
65
-
66
- function fromRandomAccessReader(reader, totalSize, options, callback) {
67
- if (typeof options === "function") {
68
- callback = options;
69
- options = null;
70
- }
71
- if (options == null) options = {};
72
- if (options.autoClose == null) options.autoClose = true;
73
- if (options.lazyEntries == null) options.lazyEntries = false;
74
- if (callback == null) callback = defaultCallback;
75
- if (typeof totalSize !== "number") throw new Error("expected totalSize parameter to be a number");
76
- if (totalSize > Number.MAX_SAFE_INTEGER) {
77
- throw new Error("zip file too large. only file sizes up to 2^52 are supported due to JavaScript's Number type being an IEEE 754 double.");
78
- }
79
-
80
- // the matching unref() call is in zipfile.close()
81
- reader.ref();
82
-
83
- // eocdr means End of Central Directory Record.
84
- // search backwards for the eocdr signature.
85
- // the last field of the eocdr is a variable-length comment.
86
- // the comment size is encoded in a 2-byte field in the eocdr, which we can't find without trudging backwards through the comment to find it.
87
- // as a consequence of this design decision, it's possible to have ambiguous zip file metadata if a coherent eocdr was in the comment.
88
- // we search backwards for a eocdr signature, and hope that whoever made the zip file was smart enough to forbid the eocdr signature in the comment.
89
- var eocdrWithoutCommentSize = 22;
90
- var maxCommentSize = 0x10000; // 2-byte size
91
- var bufferSize = Math.min(eocdrWithoutCommentSize + maxCommentSize, totalSize);
92
- var buffer = new Buffer(bufferSize);
93
- var bufferReadStart = totalSize - buffer.length;
94
- readAndAssertNoEof(reader, buffer, 0, bufferSize, bufferReadStart, function(err) {
95
- if (err) return callback(err);
96
- for (var i = bufferSize - eocdrWithoutCommentSize; i >= 0; i -= 1) {
97
- if (buffer.readUInt32LE(i) !== 0x06054b50) continue;
98
- // found eocdr
99
- var eocdrBuffer = buffer.slice(i);
100
-
101
- // 0 - End of central directory signature = 0x06054b50
102
- // 4 - Number of this disk
103
- var diskNumber = eocdrBuffer.readUInt16LE(4);
104
- if (diskNumber !== 0) return callback(new Error("multi-disk zip files are not supported: found disk number: " + diskNumber));
105
- // 6 - Disk where central directory starts
106
- // 8 - Number of central directory records on this disk
107
- // 10 - Total number of central directory records
108
- var entryCount = eocdrBuffer.readUInt16LE(10);
109
- // 12 - Size of central directory (bytes)
110
- // 16 - Offset of start of central directory, relative to start of archive
111
- var centralDirectoryOffset = eocdrBuffer.readUInt32LE(16);
112
- // 20 - Comment length
113
- var commentLength = eocdrBuffer.readUInt16LE(20);
114
- var expectedCommentLength = eocdrBuffer.length - eocdrWithoutCommentSize;
115
- if (commentLength !== expectedCommentLength) {
116
- return callback(new Error("invalid comment length. expected: " + expectedCommentLength + ". found: " + commentLength));
117
- }
118
- // 22 - Comment
119
- // the encoding is always cp437.
120
- var comment = bufferToString(eocdrBuffer, 22, eocdrBuffer.length, false);
121
-
122
- if (!(entryCount === 0xffff || centralDirectoryOffset === 0xffffffff)) {
123
- return callback(null, new ZipFile(reader, centralDirectoryOffset, totalSize, entryCount, comment, options.autoClose, options.lazyEntries));
124
- }
125
-
126
- // ZIP64 format
127
-
128
- // ZIP64 Zip64 end of central directory locator
129
- var zip64EocdlBuffer = new Buffer(20);
130
- var zip64EocdlOffset = bufferReadStart + i - zip64EocdlBuffer.length;
131
- readAndAssertNoEof(reader, zip64EocdlBuffer, 0, zip64EocdlBuffer.length, zip64EocdlOffset, function(err) {
132
- if (err) return callback(err);
133
-
134
- // 0 - zip64 end of central dir locator signature = 0x07064b50
135
- if (zip64EocdlBuffer.readUInt32LE(0) !== 0x07064b50) {
136
- return callback(new Error("invalid ZIP64 End of Central Directory Locator signature"));
137
- }
138
- // 4 - number of the disk with the start of the zip64 end of central directory
139
- // 8 - relative offset of the zip64 end of central directory record
140
- var zip64EocdrOffset = readUInt64LE(zip64EocdlBuffer, 8);
141
- // 16 - total number of disks
142
-
143
- // ZIP64 end of central directory record
144
- var zip64EocdrBuffer = new Buffer(56);
145
- readAndAssertNoEof(reader, zip64EocdrBuffer, 0, zip64EocdrBuffer.length, zip64EocdrOffset, function(err) {
146
- if (err) return callback(err);
147
-
148
- // 0 - zip64 end of central dir signature 4 bytes (0x06064b50)
149
- if (zip64EocdrBuffer.readUInt32LE(0) !== 0x06064b50) return callback(new Error("invalid ZIP64 end of central directory record signature"));
150
- // 4 - size of zip64 end of central directory record 8 bytes
151
- // 12 - version made by 2 bytes
152
- // 14 - version needed to extract 2 bytes
153
- // 16 - number of this disk 4 bytes
154
- // 20 - number of the disk with the start of the central directory 4 bytes
155
- // 24 - total number of entries in the central directory on this disk 8 bytes
156
- // 32 - total number of entries in the central directory 8 bytes
157
- entryCount = readUInt64LE(zip64EocdrBuffer, 32);
158
- // 40 - size of the central directory 8 bytes
159
- // 48 - offset of start of central directory with respect to the starting disk number 8 bytes
160
- centralDirectoryOffset = readUInt64LE(zip64EocdrBuffer, 48);
161
- // 56 - zip64 extensible data sector (variable size)
162
- return callback(null, new ZipFile(reader, centralDirectoryOffset, totalSize, entryCount, comment, options.autoClose, options.lazyEntries));
163
- });
164
- });
165
- return;
166
- }
167
- callback(new Error("end of central directory record signature not found"));
168
- });
169
- }
170
-
171
- util.inherits(ZipFile, EventEmitter);
172
- function ZipFile(reader, centralDirectoryOffset, fileSize, entryCount, comment, autoClose, lazyEntries) {
173
- var self = this;
174
- EventEmitter.call(self);
175
- self.reader = reader;
176
- // forward close events
177
- self.reader.on("error", function(err) {
178
- // error closing the fd
179
- emitError(self, err);
180
- });
181
- self.reader.once("close", function() {
182
- self.emit("close");
183
- });
184
- self.readEntryCursor = centralDirectoryOffset;
185
- self.fileSize = fileSize;
186
- self.entryCount = entryCount;
187
- self.comment = comment;
188
- self.entriesRead = 0;
189
- self.autoClose = !!autoClose;
190
- self.lazyEntries = !!lazyEntries;
191
- self.isOpen = true;
192
- self.emittedError = false;
193
-
194
- if (!self.lazyEntries) self.readEntry();
195
- }
196
- ZipFile.prototype.close = function() {
197
- if (!this.isOpen) return;
198
- this.isOpen = false;
199
- this.reader.unref();
200
- };
201
-
202
- function emitErrorAndAutoClose(self, err) {
203
- if (self.autoClose) self.close();
204
- emitError(self, err);
205
- }
206
- function emitError(self, err) {
207
- if (self.emittedError) return;
208
- self.emittedError = true;
209
- self.emit("error", err);
210
- }
211
-
212
- ZipFile.prototype.readEntry = function() {
213
- var self = this;
214
- if (self.entryCount === self.entriesRead) {
215
- // done with metadata
216
- setImmediate(function() {
217
- if (self.autoClose) self.close();
218
- if (self.emittedError) return;
219
- self.emit("end");
220
- });
221
- return;
222
- }
223
- if (self.emittedError) return;
224
- var buffer = new Buffer(46);
225
- readAndAssertNoEof(self.reader, buffer, 0, buffer.length, self.readEntryCursor, function(err) {
226
- if (err) return emitErrorAndAutoClose(self, err);
227
- if (self.emittedError) return;
228
- var entry = new Entry();
229
- // 0 - Central directory file header signature
230
- var signature = buffer.readUInt32LE(0);
231
- if (signature !== 0x02014b50) return emitErrorAndAutoClose(self, new Error("invalid central directory file header signature: 0x" + signature.toString(16)));
232
- // 4 - Version made by
233
- entry.versionMadeBy = buffer.readUInt16LE(4);
234
- // 6 - Version needed to extract (minimum)
235
- entry.versionNeededToExtract = buffer.readUInt16LE(6);
236
- // 8 - General purpose bit flag
237
- entry.generalPurposeBitFlag = buffer.readUInt16LE(8);
238
- // 10 - Compression method
239
- entry.compressionMethod = buffer.readUInt16LE(10);
240
- // 12 - File last modification time
241
- entry.lastModFileTime = buffer.readUInt16LE(12);
242
- // 14 - File last modification date
243
- entry.lastModFileDate = buffer.readUInt16LE(14);
244
- // 16 - CRC-32
245
- entry.crc32 = buffer.readUInt32LE(16);
246
- // 20 - Compressed size
247
- entry.compressedSize = buffer.readUInt32LE(20);
248
- // 24 - Uncompressed size
249
- entry.uncompressedSize = buffer.readUInt32LE(24);
250
- // 28 - File name length (n)
251
- entry.fileNameLength = buffer.readUInt16LE(28);
252
- // 30 - Extra field length (m)
253
- entry.extraFieldLength = buffer.readUInt16LE(30);
254
- // 32 - File comment length (k)
255
- entry.fileCommentLength = buffer.readUInt16LE(32);
256
- // 34 - Disk number where file starts
257
- // 36 - Internal file attributes
258
- entry.internalFileAttributes = buffer.readUInt16LE(36);
259
- // 38 - External file attributes
260
- entry.externalFileAttributes = buffer.readUInt32LE(38);
261
- // 42 - Relative offset of local file header
262
- entry.relativeOffsetOfLocalHeader = buffer.readUInt32LE(42);
263
-
264
- self.readEntryCursor += 46;
265
-
266
- buffer = new Buffer(entry.fileNameLength + entry.extraFieldLength + entry.fileCommentLength);
267
- readAndAssertNoEof(self.reader, buffer, 0, buffer.length, self.readEntryCursor, function(err) {
268
- if (err) return emitErrorAndAutoClose(self, err);
269
- if (self.emittedError) return;
270
- // 46 - File name
271
- var isUtf8 = entry.generalPurposeBitFlag & 0x800
272
- try {
273
- entry.fileName = bufferToString(buffer, 0, entry.fileNameLength, isUtf8);
274
- } catch (e) {
275
- return emitErrorAndAutoClose(self, e);
276
- }
277
-
278
- // 46+n - Extra field
279
- var fileCommentStart = entry.fileNameLength + entry.extraFieldLength;
280
- var extraFieldBuffer = buffer.slice(entry.fileNameLength, fileCommentStart);
281
- entry.extraFields = [];
282
- var i = 0;
283
- while (i < extraFieldBuffer.length) {
284
- var headerId = extraFieldBuffer.readUInt16LE(i + 0);
285
- var dataSize = extraFieldBuffer.readUInt16LE(i + 2);
286
- var dataStart = i + 4;
287
- var dataEnd = dataStart + dataSize;
288
- var dataBuffer = new Buffer(dataSize);
289
- extraFieldBuffer.copy(dataBuffer, 0, dataStart, dataEnd);
290
- entry.extraFields.push({
291
- id: headerId,
292
- data: dataBuffer,
293
- });
294
- i = dataEnd;
295
- }
296
-
297
- // 46+n+m - File comment
298
- try {
299
- entry.fileComment = bufferToString(buffer, fileCommentStart, fileCommentStart + entry.fileCommentLength, isUtf8);
300
- } catch (e) {
301
- return emitErrorAndAutoClose(self, e);
302
- }
303
-
304
- self.readEntryCursor += buffer.length;
305
- self.entriesRead += 1;
306
-
307
- if (entry.uncompressedSize === 0xffffffff ||
308
- entry.compressedSize === 0xffffffff ||
309
- entry.relativeOffsetOfLocalHeader === 0xffffffff) {
310
- // ZIP64 format
311
- // find the Zip64 Extended Information Extra Field
312
- var zip64EiefBuffer = null;
313
- for (var i = 0; i < entry.extraFields.length; i++) {
314
- var extraField = entry.extraFields[i];
315
- if (extraField.id === 0x0001) {
316
- zip64EiefBuffer = extraField.data;
317
- break;
318
- }
319
- }
320
- if (zip64EiefBuffer == null) return emitErrorAndAutoClose(self, new Error("expected Zip64 Extended Information Extra Field"));
321
- var index = 0;
322
- // 0 - Original Size 8 bytes
323
- if (entry.uncompressedSize === 0xffffffff) {
324
- if (index + 8 > zip64EiefBuffer.length) return emitErrorAndAutoClose(self, new Error("Zip64 Extended Information Extra Field does not include Original Size"));
325
- entry.uncompressedSize = readUInt64LE(zip64EiefBuffer, index);
326
- index += 8;
327
- }
328
- // 8 - Compressed Size 8 bytes
329
- if (entry.compressedSize === 0xffffffff) {
330
- if (index + 8 > zip64EiefBuffer.length) return emitErrorAndAutoClose(self, new Error("Zip64 Extended Information Extra Field does not include Compressed Size"));
331
- entry.compressedSize = readUInt64LE(zip64EiefBuffer, index);
332
- index += 8;
333
- }
334
- // 16 - Relative Header Offset 8 bytes
335
- if (entry.relativeOffsetOfLocalHeader === 0xffffffff) {
336
- if (index + 8 > zip64EiefBuffer.length) return emitErrorAndAutoClose(self, new Error("Zip64 Extended Information Extra Field does not include Relative Header Offset"));
337
- entry.relativeOffsetOfLocalHeader = readUInt64LE(zip64EiefBuffer, index);
338
- index += 8;
339
- }
340
- // 24 - Disk Start Number 4 bytes
341
- }
342
-
343
- // validate file size
344
- if (entry.compressionMethod === 0) {
345
- if (entry.compressedSize !== entry.uncompressedSize) {
346
- var msg = "compressed/uncompressed size mismatch for stored file: " + entry.compressedSize + " != " + entry.uncompressedSize;
347
- return emitErrorAndAutoClose(self, new Error(msg));
348
- }
349
- }
350
-
351
- // validate file name
352
- if (entry.fileName.indexOf("\\") !== -1) return emitErrorAndAutoClose(self, new Error("invalid characters in fileName: " + entry.fileName));
353
- if (/^[a-zA-Z]:/.test(entry.fileName) || /^\//.test(entry.fileName)) return emitErrorAndAutoClose(self, new Error("absolute path: " + entry.fileName));
354
- if (entry.fileName.split("/").indexOf("..") !== -1) return emitErrorAndAutoClose(self, new Error("invalid relative path: " + entry.fileName));
355
- self.emit("entry", entry);
356
-
357
- if (!self.lazyEntries) self.readEntry();
358
- });
359
- });
360
- };
361
-
362
- ZipFile.prototype.openReadStream = function(entry, callback) {
363
- var self = this;
364
- if (!self.isOpen) return callback(new Error("closed"));
365
- // make sure we don't lose the fd before we open the actual read stream
366
- self.reader.ref();
367
- var buffer = new Buffer(30);
368
- readAndAssertNoEof(self.reader, buffer, 0, buffer.length, entry.relativeOffsetOfLocalHeader, function(err) {
369
- try {
370
- if (err) return callback(err);
371
- // 0 - Local file header signature = 0x04034b50
372
- var signature = buffer.readUInt32LE(0);
373
- if (signature !== 0x04034b50) return callback(new Error("invalid local file header signature: 0x" + signature.toString(16)));
374
- // all this should be redundant
375
- // 4 - Version needed to extract (minimum)
376
- // 6 - General purpose bit flag
377
- // 8 - Compression method
378
- // 10 - File last modification time
379
- // 12 - File last modification date
380
- // 14 - CRC-32
381
- // 18 - Compressed size
382
- // 22 - Uncompressed size
383
- // 26 - File name length (n)
384
- var fileNameLength = buffer.readUInt16LE(26);
385
- // 28 - Extra field length (m)
386
- var extraFieldLength = buffer.readUInt16LE(28);
387
- // 30 - File name
388
- // 30+n - Extra field
389
- var localFileHeaderEnd = entry.relativeOffsetOfLocalHeader + buffer.length + fileNameLength + extraFieldLength;
390
- var compressed;
391
- if (entry.compressionMethod === 0) {
392
- // 0 - The file is stored (no compression)
393
- compressed = false;
394
- } else if (entry.compressionMethod === 8) {
395
- // 8 - The file is Deflated
396
- compressed = true;
397
- } else {
398
- return callback(new Error("unsupported compression method: " + entry.compressionMethod));
399
- }
400
- var fileDataStart = localFileHeaderEnd;
401
- var fileDataEnd = fileDataStart + entry.compressedSize;
402
- if (entry.compressedSize !== 0) {
403
- // bounds check now, because the read streams will probably not complain loud enough.
404
- // since we're dealing with an unsigned offset plus an unsigned size,
405
- // we only have 1 thing to check for.
406
- if (fileDataEnd > self.fileSize) {
407
- return callback(new Error("file data overflows file bounds: " +
408
- fileDataStart + " + " + entry.compressedSize + " > " + self.fileSize));
409
- }
410
- }
411
- var readStream = self.reader.createReadStream({start: fileDataStart, end: fileDataEnd});
412
- var endpointStream = readStream;
413
- if (compressed) {
414
- var destroyed = false;
415
- var inflateFilter = zlib.createInflateRaw();
416
- readStream.on("error", function(err) {
417
- // setImmediate here because errors can be emitted during the first call to pipe()
418
- setImmediate(function() {
419
- if (!destroyed) inflateFilter.emit("error", err);
420
- });
421
- });
422
-
423
- var checkerStream = new AssertByteCountStream(entry.uncompressedSize);
424
- inflateFilter.on("error", function(err) {
425
- // forward zlib errors to the client-visible stream
426
- setImmediate(function() {
427
- if (!destroyed) checkerStream.emit("error", err);
428
- });
429
- });
430
- checkerStream.destroy = function() {
431
- destroyed = true;
432
- inflateFilter.unpipe(checkerStream);
433
- readStream.unpipe(inflateFilter);
434
- // TODO: the inflateFilter now causes a memory leak. see Issue #27.
435
- readStream.destroy();
436
- };
437
- endpointStream = readStream.pipe(inflateFilter).pipe(checkerStream);
438
- }
439
- callback(null, endpointStream);
440
- } finally {
441
- self.reader.unref();
442
- }
443
- });
444
- };
445
-
446
- function Entry() {
447
- }
448
- Entry.prototype.getLastModDate = function() {
449
- return dosDateTimeToDate(this.lastModFileDate, this.lastModFileTime);
450
- };
451
-
452
- function dosDateTimeToDate(date, time) {
453
- var day = date & 0x1f; // 1-31
454
- var month = (date >> 5 & 0xf) - 1; // 1-12, 0-11
455
- var year = (date >> 9 & 0x7f) + 1980; // 0-128, 1980-2108
456
-
457
- var millisecond = 0;
458
- var second = (time & 0x1f) * 2; // 0-29, 0-58 (even numbers)
459
- var minute = time >> 5 & 0x3f; // 0-59
460
- var hour = time >> 11 & 0x1f; // 0-23
461
-
462
- return new Date(year, month, day, hour, minute, second, millisecond);
463
- }
464
-
465
- function readAndAssertNoEof(reader, buffer, offset, length, position, callback) {
466
- if (length === 0) {
467
- // fs.read will throw an out-of-bounds error if you try to read 0 bytes from a 0 byte file
468
- return setImmediate(function() { callback(null, new Buffer(0)); });
469
- }
470
- reader.read(buffer, offset, length, position, function(err, bytesRead) {
471
- if (err) return callback(err);
472
- if (bytesRead < length) return callback(new Error("unexpected EOF"));
473
- callback();
474
- });
475
- }
476
-
477
- util.inherits(AssertByteCountStream, Transform);
478
- function AssertByteCountStream(byteCount) {
479
- Transform.call(this);
480
- this.actualByteCount = 0;
481
- this.expectedByteCount = byteCount;
482
- }
483
- AssertByteCountStream.prototype._transform = function(chunk, encoding, cb) {
484
- this.actualByteCount += chunk.length;
485
- if (this.actualByteCount > this.expectedByteCount) {
486
- var msg = "too many bytes in the stream. expected " + this.expectedByteCount + ". got at least " + this.actualByteCount;
487
- return cb(new Error(msg));
488
- }
489
- cb(null, chunk);
490
- };
491
- AssertByteCountStream.prototype._flush = function(cb) {
492
- if (this.actualByteCount < this.expectedByteCount) {
493
- var msg = "not enough bytes in the stream. expected " + this.expectedByteCount + ". got only " + this.actualByteCount;
494
- return cb(new Error(msg));
495
- }
496
- cb();
497
- };
498
-
499
- util.inherits(RandomAccessReader, EventEmitter);
500
- function RandomAccessReader() {
501
- EventEmitter.call(this);
502
- this.refCount = 0;
503
- }
504
- RandomAccessReader.prototype.ref = function() {
505
- this.refCount += 1;
506
- };
507
- RandomAccessReader.prototype.unref = function() {
508
- var self = this;
509
- self.refCount -= 1;
510
-
511
- if (self.refCount > 0) return;
512
- if (self.refCount < 0) throw new Error("invalid unref");
513
-
514
- self.close(onCloseDone);
515
-
516
- function onCloseDone(err) {
517
- if (err) return self.emit('error', err);
518
- self.emit('close');
519
- }
520
- };
521
- RandomAccessReader.prototype.createReadStream = function(options) {
522
- var start = options.start;
523
- var end = options.end;
524
- if (start === end) {
525
- var emptyStream = new PassThrough();
526
- setImmediate(function() {
527
- emptyStream.end();
528
- });
529
- return emptyStream;
530
- }
531
- var stream = this._readStreamForRange(start, end);
532
-
533
- var destroyed = false;
534
- var refUnrefFilter = new RefUnrefFilter(this);
535
- stream.on("error", function(err) {
536
- setImmediate(function() {
537
- if (!destroyed) refUnrefFilter.emit("error", err);
538
- });
539
- });
540
- refUnrefFilter.destroy = function() {
541
- stream.unpipe(refUnrefFilter);
542
- refUnrefFilter.unref();
543
- stream.destroy();
544
- };
545
-
546
- var byteCounter = new AssertByteCountStream(end - start);
547
- refUnrefFilter.on("error", function(err) {
548
- setImmediate(function() {
549
- if (!destroyed) byteCounter.emit("error", err);
550
- });
551
- });
552
- byteCounter.destroy = function() {
553
- destroyed = true;
554
- refUnrefFilter.unpipe(byteCounter);
555
- refUnrefFilter.destroy();
556
- };
557
-
558
- return stream.pipe(refUnrefFilter).pipe(byteCounter);
559
- };
560
- RandomAccessReader.prototype._readStreamForRange = function(start, end) {
561
- throw new Error("not implemented");
562
- };
563
- RandomAccessReader.prototype.read = function(buffer, offset, length, position, callback) {
564
- var readStream = this.createReadStream({start: position, end: position + length});
565
- var writeStream = new Writable();
566
- var written = 0;
567
- writeStream._write = function(chunk, encoding, cb) {
568
- chunk.copy(buffer, offset + written, 0, chunk.length);
569
- written += chunk.length;
570
- cb();
571
- };
572
- writeStream.on("finish", callback);
573
- readStream.on("error", function(error) {
574
- callback(error);
575
- });
576
- readStream.pipe(writeStream);
577
- };
578
- RandomAccessReader.prototype.close = function(callback) {
579
- setImmediate(callback);
580
- };
581
-
582
- util.inherits(RefUnrefFilter, PassThrough);
583
- function RefUnrefFilter(context) {
584
- PassThrough.call(this);
585
- this.context = context;
586
- this.context.ref();
587
- this.unreffedYet = false;
588
- }
589
- RefUnrefFilter.prototype._flush = function(cb) {
590
- this.unref();
591
- cb();
592
- };
593
- RefUnrefFilter.prototype.unref = function(cb) {
594
- if (this.unreffedYet) return;
595
- this.unreffedYet = true;
596
- this.context.unref();
597
- };
598
-
599
- var cp437 = '\u0000☺☻♥♦♣♠•◘○◙♂♀♪♫☼►◄↕‼¶§▬↨↑↓→←∟↔▲▼ !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~⌂ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñѪº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ ';
600
- function bufferToString(buffer, start, end, isUtf8) {
601
- if (isUtf8) {
602
- return buffer.toString("utf8", start, end);
603
- } else {
604
- var result = "";
605
- for (var i = start; i < end; i++) {
606
- result += cp437[buffer[i]];
607
- }
608
- return result;
609
- }
610
- }
611
-
612
- function readUInt64LE(buffer, offset) {
613
- // there is no native function for this, because we can't actually store 64-bit integers precisely.
614
- // after 53 bits, JavaScript's Number type (IEEE 754 double) can't store individual integers anymore.
615
- // but since 53 bits is a whole lot more than 32 bits, we do our best anyway.
616
- var lower32 = buffer.readUInt32LE(offset);
617
- var upper32 = buffer.readUInt32LE(offset + 4);
618
- // we can't use bitshifting here, because JavaScript bitshifting only works on 32-bit integers.
619
- return upper32 * 0x100000000 + lower32;
620
- // as long as we're bounds checking the result of this function against the total file size,
621
- // we'll catch any overflow errors, because we already made sure the total file size was within reason.
622
- }
623
-
624
- function defaultCallback(err) {
625
- if (err) throw err;
626
- }