node-datachannel 0.1.8

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 (444) hide show
  1. package/.github/workflows/build-linux.yml +109 -0
  2. package/.github/workflows/build-mac.yml +40 -0
  3. package/.github/workflows/build-win.yml +77 -0
  4. package/.github/workflows/npm-publish-manual.yml +23 -0
  5. package/CMakeLists.txt +73 -0
  6. package/LICENSE +504 -0
  7. package/README.md +180 -0
  8. package/cmake/toolchain/arm64.cmake +17 -0
  9. package/cmake/toolchain/armv7.cmake +17 -0
  10. package/examples/README.md +21 -0
  11. package/examples/client-server/client-benchmark.js +216 -0
  12. package/examples/client-server/client-periodic.js +176 -0
  13. package/examples/client-server/client.js +113 -0
  14. package/examples/client-server/package-lock.json +126 -0
  15. package/examples/client-server/package.json +16 -0
  16. package/examples/client-server/signaling-server.js +31 -0
  17. package/lib/index.d.ts +123 -0
  18. package/lib/index.js +2 -0
  19. package/node_modules/ansi-regex/index.js +4 -0
  20. package/node_modules/ansi-regex/license +21 -0
  21. package/node_modules/ansi-regex/package.json +111 -0
  22. package/node_modules/ansi-regex/readme.md +39 -0
  23. package/node_modules/aproba/LICENSE +14 -0
  24. package/node_modules/aproba/README.md +94 -0
  25. package/node_modules/aproba/index.js +105 -0
  26. package/node_modules/aproba/package.json +65 -0
  27. package/node_modules/base64-js/LICENSE +21 -0
  28. package/node_modules/base64-js/README.md +34 -0
  29. package/node_modules/base64-js/base64js.min.js +1 -0
  30. package/node_modules/base64-js/index.d.ts +3 -0
  31. package/node_modules/base64-js/index.js +150 -0
  32. package/node_modules/base64-js/package.json +78 -0
  33. package/node_modules/buffer/AUTHORS.md +70 -0
  34. package/node_modules/buffer/LICENSE +21 -0
  35. package/node_modules/buffer/README.md +410 -0
  36. package/node_modules/buffer/index.d.ts +186 -0
  37. package/node_modules/buffer/index.js +1817 -0
  38. package/node_modules/buffer/package.json +130 -0
  39. package/node_modules/chownr/LICENSE +15 -0
  40. package/node_modules/chownr/README.md +3 -0
  41. package/node_modules/chownr/chownr.js +167 -0
  42. package/node_modules/chownr/package.json +66 -0
  43. package/node_modules/code-point-at/index.js +32 -0
  44. package/node_modules/code-point-at/license +21 -0
  45. package/node_modules/code-point-at/package.json +73 -0
  46. package/node_modules/code-point-at/readme.md +32 -0
  47. package/node_modules/console-control-strings/LICENSE +13 -0
  48. package/node_modules/console-control-strings/README.md +145 -0
  49. package/node_modules/console-control-strings/README.md~ +140 -0
  50. package/node_modules/console-control-strings/index.js +125 -0
  51. package/node_modules/console-control-strings/package.json +64 -0
  52. package/node_modules/core-util-is/LICENSE +19 -0
  53. package/node_modules/core-util-is/README.md +3 -0
  54. package/node_modules/core-util-is/float.patch +604 -0
  55. package/node_modules/core-util-is/lib/util.js +107 -0
  56. package/node_modules/core-util-is/package.json +70 -0
  57. package/node_modules/core-util-is/test.js +68 -0
  58. package/node_modules/decompress-response/index.d.ts +29 -0
  59. package/node_modules/decompress-response/index.js +40 -0
  60. package/node_modules/decompress-response/license +9 -0
  61. package/node_modules/decompress-response/package.json +85 -0
  62. package/node_modules/decompress-response/readme.md +52 -0
  63. package/node_modules/deep-extend/CHANGELOG.md +46 -0
  64. package/node_modules/deep-extend/LICENSE +20 -0
  65. package/node_modules/deep-extend/README.md +91 -0
  66. package/node_modules/deep-extend/index.js +1 -0
  67. package/node_modules/deep-extend/lib/deep-extend.js +150 -0
  68. package/node_modules/deep-extend/package.json +95 -0
  69. package/node_modules/delegates/.npmignore +1 -0
  70. package/node_modules/delegates/History.md +22 -0
  71. package/node_modules/delegates/License +20 -0
  72. package/node_modules/delegates/Makefile +8 -0
  73. package/node_modules/delegates/Readme.md +94 -0
  74. package/node_modules/delegates/index.js +121 -0
  75. package/node_modules/delegates/package.json +54 -0
  76. package/node_modules/delegates/test/index.js +94 -0
  77. package/node_modules/detect-libc/.npmignore +7 -0
  78. package/node_modules/detect-libc/LICENSE +201 -0
  79. package/node_modules/detect-libc/README.md +78 -0
  80. package/node_modules/detect-libc/bin/detect-libc.js +18 -0
  81. package/node_modules/detect-libc/lib/detect-libc.js +92 -0
  82. package/node_modules/detect-libc/package.json +74 -0
  83. package/node_modules/end-of-stream/LICENSE +21 -0
  84. package/node_modules/end-of-stream/README.md +54 -0
  85. package/node_modules/end-of-stream/index.js +94 -0
  86. package/node_modules/end-of-stream/package.json +69 -0
  87. package/node_modules/expand-template/.travis.yml +6 -0
  88. package/node_modules/expand-template/LICENSE +21 -0
  89. package/node_modules/expand-template/README.md +43 -0
  90. package/node_modules/expand-template/index.js +26 -0
  91. package/node_modules/expand-template/package.json +63 -0
  92. package/node_modules/expand-template/test.js +67 -0
  93. package/node_modules/fs-constants/LICENSE +21 -0
  94. package/node_modules/fs-constants/README.md +26 -0
  95. package/node_modules/fs-constants/browser.js +1 -0
  96. package/node_modules/fs-constants/index.js +1 -0
  97. package/node_modules/fs-constants/package.json +50 -0
  98. package/node_modules/github-from-package/.travis.yml +4 -0
  99. package/node_modules/github-from-package/LICENSE +18 -0
  100. package/node_modules/github-from-package/example/package.json +8 -0
  101. package/node_modules/github-from-package/example/url.js +3 -0
  102. package/node_modules/github-from-package/index.js +17 -0
  103. package/node_modules/github-from-package/package.json +62 -0
  104. package/node_modules/github-from-package/readme.markdown +53 -0
  105. package/node_modules/github-from-package/test/a.json +8 -0
  106. package/node_modules/github-from-package/test/b.json +5 -0
  107. package/node_modules/github-from-package/test/c.json +5 -0
  108. package/node_modules/github-from-package/test/d.json +7 -0
  109. package/node_modules/github-from-package/test/e.json +5 -0
  110. package/node_modules/github-from-package/test/url.js +19 -0
  111. package/node_modules/has-unicode/LICENSE +14 -0
  112. package/node_modules/has-unicode/README.md +43 -0
  113. package/node_modules/has-unicode/index.js +16 -0
  114. package/node_modules/has-unicode/package.json +63 -0
  115. package/node_modules/ieee754/LICENSE +11 -0
  116. package/node_modules/ieee754/README.md +51 -0
  117. package/node_modules/ieee754/index.d.ts +10 -0
  118. package/node_modules/ieee754/index.js +85 -0
  119. package/node_modules/ieee754/package.json +87 -0
  120. package/node_modules/inherits/LICENSE +16 -0
  121. package/node_modules/inherits/README.md +42 -0
  122. package/node_modules/inherits/inherits.js +9 -0
  123. package/node_modules/inherits/inherits_browser.js +27 -0
  124. package/node_modules/inherits/package.json +78 -0
  125. package/node_modules/ini/LICENSE +15 -0
  126. package/node_modules/ini/README.md +102 -0
  127. package/node_modules/ini/ini.js +194 -0
  128. package/node_modules/ini/package.json +66 -0
  129. package/node_modules/is-fullwidth-code-point/index.js +46 -0
  130. package/node_modules/is-fullwidth-code-point/license +21 -0
  131. package/node_modules/is-fullwidth-code-point/package.json +80 -0
  132. package/node_modules/is-fullwidth-code-point/readme.md +39 -0
  133. package/node_modules/isarray/.npmignore +1 -0
  134. package/node_modules/isarray/.travis.yml +4 -0
  135. package/node_modules/isarray/Makefile +6 -0
  136. package/node_modules/isarray/README.md +60 -0
  137. package/node_modules/isarray/component.json +19 -0
  138. package/node_modules/isarray/index.js +5 -0
  139. package/node_modules/isarray/package.json +77 -0
  140. package/node_modules/isarray/test.js +20 -0
  141. package/node_modules/mimic-response/index.d.ts +17 -0
  142. package/node_modules/mimic-response/index.js +38 -0
  143. package/node_modules/mimic-response/license +9 -0
  144. package/node_modules/mimic-response/package.json +77 -0
  145. package/node_modules/mimic-response/readme.md +57 -0
  146. package/node_modules/minimist/.travis.yml +8 -0
  147. package/node_modules/minimist/LICENSE +18 -0
  148. package/node_modules/minimist/example/parse.js +2 -0
  149. package/node_modules/minimist/index.js +245 -0
  150. package/node_modules/minimist/package.json +80 -0
  151. package/node_modules/minimist/readme.markdown +95 -0
  152. package/node_modules/minimist/test/all_bool.js +32 -0
  153. package/node_modules/minimist/test/bool.js +178 -0
  154. package/node_modules/minimist/test/dash.js +31 -0
  155. package/node_modules/minimist/test/default_bool.js +35 -0
  156. package/node_modules/minimist/test/dotted.js +22 -0
  157. package/node_modules/minimist/test/kv_short.js +16 -0
  158. package/node_modules/minimist/test/long.js +31 -0
  159. package/node_modules/minimist/test/num.js +36 -0
  160. package/node_modules/minimist/test/parse.js +197 -0
  161. package/node_modules/minimist/test/parse_modified.js +9 -0
  162. package/node_modules/minimist/test/proto.js +44 -0
  163. package/node_modules/minimist/test/short.js +67 -0
  164. package/node_modules/minimist/test/stop_early.js +15 -0
  165. package/node_modules/minimist/test/unknown.js +102 -0
  166. package/node_modules/minimist/test/whitespace.js +8 -0
  167. package/node_modules/mkdirp-classic/LICENSE +21 -0
  168. package/node_modules/mkdirp-classic/README.md +18 -0
  169. package/node_modules/mkdirp-classic/index.js +98 -0
  170. package/node_modules/mkdirp-classic/package.json +50 -0
  171. package/node_modules/napi-build-utils/LICENSE +21 -0
  172. package/node_modules/napi-build-utils/README.md +48 -0
  173. package/node_modules/napi-build-utils/index.js +213 -0
  174. package/node_modules/napi-build-utils/index.md +81 -0
  175. package/node_modules/napi-build-utils/package.json +72 -0
  176. package/node_modules/node-abi/.github/workflows/update-abi.yml +41 -0
  177. package/node_modules/node-abi/.travis.yml +19 -0
  178. package/node_modules/node-abi/CODE_OF_CONDUCT.md +73 -0
  179. package/node_modules/node-abi/CONTRIBUTING.md +53 -0
  180. package/node_modules/node-abi/LICENSE +21 -0
  181. package/node_modules/node-abi/README.md +50 -0
  182. package/node_modules/node-abi/abi_registry.json +99 -0
  183. package/node_modules/node-abi/index.js +170 -0
  184. package/node_modules/node-abi/package.json +69 -0
  185. package/node_modules/node-abi/scripts/update-abi-registry.js +113 -0
  186. package/node_modules/node-abi/test/index.js +174 -0
  187. package/node_modules/noop-logger/.npmignore +1 -0
  188. package/node_modules/noop-logger/History.md +16 -0
  189. package/node_modules/noop-logger/Makefile +8 -0
  190. package/node_modules/noop-logger/Readme.md +27 -0
  191. package/node_modules/noop-logger/circle.yml +9 -0
  192. package/node_modules/noop-logger/lib/index.js +25 -0
  193. package/node_modules/noop-logger/package.json +51 -0
  194. package/node_modules/noop-logger/test/index.js +18 -0
  195. package/node_modules/npmlog/CHANGELOG.md +49 -0
  196. package/node_modules/npmlog/LICENSE +15 -0
  197. package/node_modules/npmlog/README.md +216 -0
  198. package/node_modules/npmlog/log.js +309 -0
  199. package/node_modules/npmlog/node_modules/are-we-there-yet/CHANGES.md +37 -0
  200. package/node_modules/npmlog/node_modules/are-we-there-yet/LICENSE +5 -0
  201. package/node_modules/npmlog/node_modules/are-we-there-yet/README.md +195 -0
  202. package/node_modules/npmlog/node_modules/are-we-there-yet/index.js +4 -0
  203. package/node_modules/npmlog/node_modules/are-we-there-yet/package.json +66 -0
  204. package/node_modules/npmlog/node_modules/are-we-there-yet/tracker-base.js +11 -0
  205. package/node_modules/npmlog/node_modules/are-we-there-yet/tracker-group.js +107 -0
  206. package/node_modules/npmlog/node_modules/are-we-there-yet/tracker-stream.js +36 -0
  207. package/node_modules/npmlog/node_modules/are-we-there-yet/tracker.js +30 -0
  208. package/node_modules/npmlog/node_modules/gauge/CHANGELOG.md +160 -0
  209. package/node_modules/npmlog/node_modules/gauge/LICENSE +13 -0
  210. package/node_modules/npmlog/node_modules/gauge/README.md +399 -0
  211. package/node_modules/npmlog/node_modules/gauge/base-theme.js +14 -0
  212. package/node_modules/npmlog/node_modules/gauge/error.js +24 -0
  213. package/node_modules/npmlog/node_modules/gauge/has-color.js +12 -0
  214. package/node_modules/npmlog/node_modules/gauge/index.js +233 -0
  215. package/node_modules/npmlog/node_modules/gauge/package.json +94 -0
  216. package/node_modules/npmlog/node_modules/gauge/plumbing.js +48 -0
  217. package/node_modules/npmlog/node_modules/gauge/process.js +3 -0
  218. package/node_modules/npmlog/node_modules/gauge/progress-bar.js +35 -0
  219. package/node_modules/npmlog/node_modules/gauge/render-template.js +181 -0
  220. package/node_modules/npmlog/node_modules/gauge/set-immediate.js +7 -0
  221. package/node_modules/npmlog/node_modules/gauge/set-interval.js +3 -0
  222. package/node_modules/npmlog/node_modules/gauge/spin.js +5 -0
  223. package/node_modules/npmlog/node_modules/gauge/template-item.js +73 -0
  224. package/node_modules/npmlog/node_modules/gauge/theme-set.js +115 -0
  225. package/node_modules/npmlog/node_modules/gauge/themes.js +54 -0
  226. package/node_modules/npmlog/node_modules/gauge/wide-truncate.js +25 -0
  227. package/node_modules/npmlog/package.json +78 -0
  228. package/node_modules/number-is-nan/index.js +4 -0
  229. package/node_modules/number-is-nan/license +21 -0
  230. package/node_modules/number-is-nan/package.json +70 -0
  231. package/node_modules/number-is-nan/readme.md +28 -0
  232. package/node_modules/object-assign/index.js +90 -0
  233. package/node_modules/object-assign/license +21 -0
  234. package/node_modules/object-assign/package.json +77 -0
  235. package/node_modules/object-assign/readme.md +61 -0
  236. package/node_modules/once/LICENSE +15 -0
  237. package/node_modules/once/README.md +79 -0
  238. package/node_modules/once/once.js +42 -0
  239. package/node_modules/once/package.json +74 -0
  240. package/node_modules/prebuild-install/.travis.yml +12 -0
  241. package/node_modules/prebuild-install/CHANGELOG.md +7 -0
  242. package/node_modules/prebuild-install/CONTRIBUTING.md +6 -0
  243. package/node_modules/prebuild-install/LICENSE +21 -0
  244. package/node_modules/prebuild-install/README.md +108 -0
  245. package/node_modules/prebuild-install/appveyor.yml +40 -0
  246. package/node_modules/prebuild-install/asset.js +48 -0
  247. package/node_modules/prebuild-install/bin.js +85 -0
  248. package/node_modules/prebuild-install/download.js +130 -0
  249. package/node_modules/prebuild-install/error.js +14 -0
  250. package/node_modules/prebuild-install/help.txt +14 -0
  251. package/node_modules/prebuild-install/index.js +1 -0
  252. package/node_modules/prebuild-install/log.js +13 -0
  253. package/node_modules/prebuild-install/package.json +131 -0
  254. package/node_modules/prebuild-install/proxy.js +38 -0
  255. package/node_modules/prebuild-install/rc.js +81 -0
  256. package/node_modules/prebuild-install/util.js +97 -0
  257. package/node_modules/process-nextick-args/index.js +45 -0
  258. package/node_modules/process-nextick-args/license.md +19 -0
  259. package/node_modules/process-nextick-args/package.json +53 -0
  260. package/node_modules/process-nextick-args/readme.md +18 -0
  261. package/node_modules/pump/.travis.yml +5 -0
  262. package/node_modules/pump/LICENSE +21 -0
  263. package/node_modules/pump/README.md +65 -0
  264. package/node_modules/pump/index.js +82 -0
  265. package/node_modules/pump/package.json +63 -0
  266. package/node_modules/pump/test-browser.js +66 -0
  267. package/node_modules/pump/test-node.js +53 -0
  268. package/node_modules/rc/LICENSE.APACHE2 +15 -0
  269. package/node_modules/rc/LICENSE.BSD +26 -0
  270. package/node_modules/rc/LICENSE.MIT +24 -0
  271. package/node_modules/rc/README.md +227 -0
  272. package/node_modules/rc/browser.js +7 -0
  273. package/node_modules/rc/cli.js +4 -0
  274. package/node_modules/rc/index.js +53 -0
  275. package/node_modules/rc/lib/utils.js +104 -0
  276. package/node_modules/rc/package.json +70 -0
  277. package/node_modules/rc/test/ini.js +16 -0
  278. package/node_modules/rc/test/nested-env-vars.js +50 -0
  279. package/node_modules/rc/test/test.js +59 -0
  280. package/node_modules/readable-stream/.travis.yml +34 -0
  281. package/node_modules/readable-stream/CONTRIBUTING.md +38 -0
  282. package/node_modules/readable-stream/GOVERNANCE.md +136 -0
  283. package/node_modules/readable-stream/LICENSE +47 -0
  284. package/node_modules/readable-stream/README.md +58 -0
  285. package/node_modules/readable-stream/doc/wg-meetings/2015-01-30.md +60 -0
  286. package/node_modules/readable-stream/duplex-browser.js +1 -0
  287. package/node_modules/readable-stream/duplex.js +1 -0
  288. package/node_modules/readable-stream/lib/_stream_duplex.js +131 -0
  289. package/node_modules/readable-stream/lib/_stream_passthrough.js +47 -0
  290. package/node_modules/readable-stream/lib/_stream_readable.js +1019 -0
  291. package/node_modules/readable-stream/lib/_stream_transform.js +214 -0
  292. package/node_modules/readable-stream/lib/_stream_writable.js +687 -0
  293. package/node_modules/readable-stream/lib/internal/streams/BufferList.js +79 -0
  294. package/node_modules/readable-stream/lib/internal/streams/destroy.js +74 -0
  295. package/node_modules/readable-stream/lib/internal/streams/stream-browser.js +1 -0
  296. package/node_modules/readable-stream/lib/internal/streams/stream.js +1 -0
  297. package/node_modules/readable-stream/package.json +88 -0
  298. package/node_modules/readable-stream/passthrough.js +1 -0
  299. package/node_modules/readable-stream/readable-browser.js +7 -0
  300. package/node_modules/readable-stream/readable.js +19 -0
  301. package/node_modules/readable-stream/transform.js +1 -0
  302. package/node_modules/readable-stream/writable-browser.js +1 -0
  303. package/node_modules/readable-stream/writable.js +8 -0
  304. package/node_modules/safe-buffer/LICENSE +21 -0
  305. package/node_modules/safe-buffer/README.md +584 -0
  306. package/node_modules/safe-buffer/index.d.ts +187 -0
  307. package/node_modules/safe-buffer/index.js +62 -0
  308. package/node_modules/safe-buffer/package.json +71 -0
  309. package/node_modules/semver/CHANGELOG.md +39 -0
  310. package/node_modules/semver/LICENSE +15 -0
  311. package/node_modules/semver/README.md +412 -0
  312. package/node_modules/semver/bin/semver +160 -0
  313. package/node_modules/semver/package.json +67 -0
  314. package/node_modules/semver/range.bnf +16 -0
  315. package/node_modules/semver/semver.js +1483 -0
  316. package/node_modules/set-blocking/CHANGELOG.md +26 -0
  317. package/node_modules/set-blocking/LICENSE.txt +14 -0
  318. package/node_modules/set-blocking/README.md +31 -0
  319. package/node_modules/set-blocking/index.js +7 -0
  320. package/node_modules/set-blocking/package.json +73 -0
  321. package/node_modules/signal-exit/CHANGELOG.md +35 -0
  322. package/node_modules/signal-exit/LICENSE.txt +16 -0
  323. package/node_modules/signal-exit/README.md +39 -0
  324. package/node_modules/signal-exit/index.js +163 -0
  325. package/node_modules/signal-exit/package.json +71 -0
  326. package/node_modules/signal-exit/signals.js +53 -0
  327. package/node_modules/simple-concat/.travis.yml +3 -0
  328. package/node_modules/simple-concat/LICENSE +20 -0
  329. package/node_modules/simple-concat/README.md +44 -0
  330. package/node_modules/simple-concat/index.js +15 -0
  331. package/node_modules/simple-concat/package.json +75 -0
  332. package/node_modules/simple-concat/test/basic.js +41 -0
  333. package/node_modules/simple-get/LICENSE +20 -0
  334. package/node_modules/simple-get/README.md +319 -0
  335. package/node_modules/simple-get/index.js +99 -0
  336. package/node_modules/simple-get/package.json +81 -0
  337. package/node_modules/string-width/index.js +37 -0
  338. package/node_modules/string-width/license +21 -0
  339. package/node_modules/string-width/package.json +96 -0
  340. package/node_modules/string-width/readme.md +42 -0
  341. package/node_modules/string_decoder/.travis.yml +50 -0
  342. package/node_modules/string_decoder/LICENSE +48 -0
  343. package/node_modules/string_decoder/README.md +47 -0
  344. package/node_modules/string_decoder/lib/string_decoder.js +296 -0
  345. package/node_modules/string_decoder/package.json +64 -0
  346. package/node_modules/strip-ansi/index.js +6 -0
  347. package/node_modules/strip-ansi/license +21 -0
  348. package/node_modules/strip-ansi/package.json +107 -0
  349. package/node_modules/strip-ansi/readme.md +33 -0
  350. package/node_modules/strip-json-comments/index.js +70 -0
  351. package/node_modules/strip-json-comments/license +21 -0
  352. package/node_modules/strip-json-comments/package.json +77 -0
  353. package/node_modules/strip-json-comments/readme.md +64 -0
  354. package/node_modules/tar-fs/.travis.yml +6 -0
  355. package/node_modules/tar-fs/LICENSE +21 -0
  356. package/node_modules/tar-fs/README.md +165 -0
  357. package/node_modules/tar-fs/index.js +351 -0
  358. package/node_modules/tar-fs/package.json +71 -0
  359. package/node_modules/tar-fs/test/fixtures/a/hello.txt +1 -0
  360. package/node_modules/tar-fs/test/fixtures/b/a/test.txt +1 -0
  361. package/node_modules/tar-fs/test/fixtures/d/file1 +0 -0
  362. package/node_modules/tar-fs/test/fixtures/d/file2 +0 -0
  363. package/node_modules/tar-fs/test/fixtures/d/sub-dir/file5 +0 -0
  364. package/node_modules/tar-fs/test/fixtures/d/sub-files/file3 +0 -0
  365. package/node_modules/tar-fs/test/fixtures/d/sub-files/file4 +0 -0
  366. package/node_modules/tar-fs/test/fixtures/e/directory/.ignore +0 -0
  367. package/node_modules/tar-fs/test/fixtures/e/file +0 -0
  368. package/node_modules/tar-fs/test/fixtures/invalid.tar +0 -0
  369. package/node_modules/tar-fs/test/index.js +346 -0
  370. package/node_modules/tar-stream/LICENSE +21 -0
  371. package/node_modules/tar-stream/README.md +168 -0
  372. package/node_modules/tar-stream/extract.js +257 -0
  373. package/node_modules/tar-stream/headers.js +293 -0
  374. package/node_modules/tar-stream/index.js +2 -0
  375. package/node_modules/tar-stream/node_modules/bl/.travis.yml +16 -0
  376. package/node_modules/tar-stream/node_modules/bl/BufferList.js +396 -0
  377. package/node_modules/tar-stream/node_modules/bl/LICENSE.md +13 -0
  378. package/node_modules/tar-stream/node_modules/bl/README.md +247 -0
  379. package/node_modules/tar-stream/node_modules/bl/bl.js +84 -0
  380. package/node_modules/tar-stream/node_modules/bl/package.json +68 -0
  381. package/node_modules/tar-stream/node_modules/bl/test/convert.js +21 -0
  382. package/node_modules/tar-stream/node_modules/bl/test/indexOf.js +492 -0
  383. package/node_modules/tar-stream/node_modules/bl/test/isBufferList.js +32 -0
  384. package/node_modules/tar-stream/node_modules/bl/test/test.js +851 -0
  385. package/node_modules/tar-stream/node_modules/readable-stream/CONTRIBUTING.md +38 -0
  386. package/node_modules/tar-stream/node_modules/readable-stream/GOVERNANCE.md +136 -0
  387. package/node_modules/tar-stream/node_modules/readable-stream/LICENSE +47 -0
  388. package/node_modules/tar-stream/node_modules/readable-stream/README.md +106 -0
  389. package/node_modules/tar-stream/node_modules/readable-stream/errors-browser.js +127 -0
  390. package/node_modules/tar-stream/node_modules/readable-stream/errors.js +116 -0
  391. package/node_modules/tar-stream/node_modules/readable-stream/experimentalWarning.js +17 -0
  392. package/node_modules/tar-stream/node_modules/readable-stream/lib/_stream_duplex.js +139 -0
  393. package/node_modules/tar-stream/node_modules/readable-stream/lib/_stream_passthrough.js +39 -0
  394. package/node_modules/tar-stream/node_modules/readable-stream/lib/_stream_readable.js +1124 -0
  395. package/node_modules/tar-stream/node_modules/readable-stream/lib/_stream_transform.js +201 -0
  396. package/node_modules/tar-stream/node_modules/readable-stream/lib/_stream_writable.js +697 -0
  397. package/node_modules/tar-stream/node_modules/readable-stream/lib/internal/streams/async_iterator.js +207 -0
  398. package/node_modules/tar-stream/node_modules/readable-stream/lib/internal/streams/buffer_list.js +210 -0
  399. package/node_modules/tar-stream/node_modules/readable-stream/lib/internal/streams/destroy.js +105 -0
  400. package/node_modules/tar-stream/node_modules/readable-stream/lib/internal/streams/end-of-stream.js +104 -0
  401. package/node_modules/tar-stream/node_modules/readable-stream/lib/internal/streams/from-browser.js +3 -0
  402. package/node_modules/tar-stream/node_modules/readable-stream/lib/internal/streams/from.js +64 -0
  403. package/node_modules/tar-stream/node_modules/readable-stream/lib/internal/streams/pipeline.js +97 -0
  404. package/node_modules/tar-stream/node_modules/readable-stream/lib/internal/streams/state.js +27 -0
  405. package/node_modules/tar-stream/node_modules/readable-stream/lib/internal/streams/stream-browser.js +1 -0
  406. package/node_modules/tar-stream/node_modules/readable-stream/lib/internal/streams/stream.js +1 -0
  407. package/node_modules/tar-stream/node_modules/readable-stream/package.json +101 -0
  408. package/node_modules/tar-stream/node_modules/readable-stream/readable-browser.js +9 -0
  409. package/node_modules/tar-stream/node_modules/readable-stream/readable.js +16 -0
  410. package/node_modules/tar-stream/pack.js +255 -0
  411. package/node_modules/tar-stream/package.json +95 -0
  412. package/node_modules/tar-stream/sandbox.js +11 -0
  413. package/node_modules/tunnel-agent/LICENSE +55 -0
  414. package/node_modules/tunnel-agent/README.md +4 -0
  415. package/node_modules/tunnel-agent/index.js +244 -0
  416. package/node_modules/tunnel-agent/package.json +59 -0
  417. package/node_modules/util-deprecate/History.md +16 -0
  418. package/node_modules/util-deprecate/LICENSE +24 -0
  419. package/node_modules/util-deprecate/README.md +53 -0
  420. package/node_modules/util-deprecate/browser.js +67 -0
  421. package/node_modules/util-deprecate/node.js +6 -0
  422. package/node_modules/util-deprecate/package.json +62 -0
  423. package/node_modules/which-pm-runs/LICENSE +21 -0
  424. package/node_modules/which-pm-runs/README.md +29 -0
  425. package/node_modules/which-pm-runs/index.js +17 -0
  426. package/node_modules/which-pm-runs/package.json +64 -0
  427. package/node_modules/wide-align/LICENSE +14 -0
  428. package/node_modules/wide-align/README.md +47 -0
  429. package/node_modules/wide-align/align.js +65 -0
  430. package/node_modules/wide-align/package.json +69 -0
  431. package/node_modules/wrappy/LICENSE +15 -0
  432. package/node_modules/wrappy/README.md +36 -0
  433. package/node_modules/wrappy/package.json +62 -0
  434. package/node_modules/wrappy/wrappy.js +33 -0
  435. package/package.json +48 -0
  436. package/src/data-channel-wrapper.cpp +401 -0
  437. package/src/data-channel-wrapper.h +52 -0
  438. package/src/main.cpp +14 -0
  439. package/src/peer-connection-wrapper.cpp +720 -0
  440. package/src/peer-connection-wrapper.h +55 -0
  441. package/src/rtc-wrapper.cpp +110 -0
  442. package/src/rtc-wrapper.h +19 -0
  443. package/test/connectivity.js +100 -0
  444. package/test/test.js +149 -0
@@ -0,0 +1,32 @@
1
+ 'use strict'
2
+
3
+ const tape = require('tape')
4
+ const { BufferList, BufferListStream } = require('../')
5
+ const { Buffer } = require('buffer')
6
+
7
+ tape('isBufferList positives', (t) => {
8
+ t.ok(BufferList.isBufferList(new BufferList()))
9
+ t.ok(BufferList.isBufferList(new BufferListStream()))
10
+
11
+ t.end()
12
+ })
13
+
14
+ tape('isBufferList negatives', (t) => {
15
+ const types = [
16
+ null,
17
+ undefined,
18
+ NaN,
19
+ true,
20
+ false,
21
+ {},
22
+ [],
23
+ Buffer.alloc(0),
24
+ [Buffer.alloc(0)]
25
+ ]
26
+
27
+ for (const obj of types) {
28
+ t.notOk(BufferList.isBufferList(obj))
29
+ }
30
+
31
+ t.end()
32
+ })
@@ -0,0 +1,851 @@
1
+ 'use strict'
2
+
3
+ const tape = require('tape')
4
+ const crypto = require('crypto')
5
+ const fs = require('fs')
6
+ const path = require('path')
7
+ const BufferList = require('../')
8
+ const { Buffer } = require('buffer')
9
+
10
+ const encodings =
11
+ ('hex utf8 utf-8 ascii binary base64' +
12
+ (process.browser ? '' : ' ucs2 ucs-2 utf16le utf-16le')).split(' ')
13
+
14
+ require('./indexOf')
15
+ require('./isBufferList')
16
+ require('./convert')
17
+
18
+ tape('single bytes from single buffer', function (t) {
19
+ const bl = new BufferList()
20
+
21
+ bl.append(Buffer.from('abcd'))
22
+
23
+ t.equal(bl.length, 4)
24
+ t.equal(bl.get(-1), undefined)
25
+ t.equal(bl.get(0), 97)
26
+ t.equal(bl.get(1), 98)
27
+ t.equal(bl.get(2), 99)
28
+ t.equal(bl.get(3), 100)
29
+ t.equal(bl.get(4), undefined)
30
+
31
+ t.end()
32
+ })
33
+
34
+ tape('single bytes from multiple buffers', function (t) {
35
+ const bl = new BufferList()
36
+
37
+ bl.append(Buffer.from('abcd'))
38
+ bl.append(Buffer.from('efg'))
39
+ bl.append(Buffer.from('hi'))
40
+ bl.append(Buffer.from('j'))
41
+
42
+ t.equal(bl.length, 10)
43
+
44
+ t.equal(bl.get(0), 97)
45
+ t.equal(bl.get(1), 98)
46
+ t.equal(bl.get(2), 99)
47
+ t.equal(bl.get(3), 100)
48
+ t.equal(bl.get(4), 101)
49
+ t.equal(bl.get(5), 102)
50
+ t.equal(bl.get(6), 103)
51
+ t.equal(bl.get(7), 104)
52
+ t.equal(bl.get(8), 105)
53
+ t.equal(bl.get(9), 106)
54
+
55
+ t.end()
56
+ })
57
+
58
+ tape('multi bytes from single buffer', function (t) {
59
+ const bl = new BufferList()
60
+
61
+ bl.append(Buffer.from('abcd'))
62
+
63
+ t.equal(bl.length, 4)
64
+
65
+ t.equal(bl.slice(0, 4).toString('ascii'), 'abcd')
66
+ t.equal(bl.slice(0, 3).toString('ascii'), 'abc')
67
+ t.equal(bl.slice(1, 4).toString('ascii'), 'bcd')
68
+ t.equal(bl.slice(-4, -1).toString('ascii'), 'abc')
69
+
70
+ t.end()
71
+ })
72
+
73
+ tape('multi bytes from single buffer (negative indexes)', function (t) {
74
+ const bl = new BufferList()
75
+
76
+ bl.append(Buffer.from('buffer'))
77
+
78
+ t.equal(bl.length, 6)
79
+
80
+ t.equal(bl.slice(-6, -1).toString('ascii'), 'buffe')
81
+ t.equal(bl.slice(-6, -2).toString('ascii'), 'buff')
82
+ t.equal(bl.slice(-5, -2).toString('ascii'), 'uff')
83
+
84
+ t.end()
85
+ })
86
+
87
+ tape('multiple bytes from multiple buffers', function (t) {
88
+ const bl = new BufferList()
89
+
90
+ bl.append(Buffer.from('abcd'))
91
+ bl.append(Buffer.from('efg'))
92
+ bl.append(Buffer.from('hi'))
93
+ bl.append(Buffer.from('j'))
94
+
95
+ t.equal(bl.length, 10)
96
+
97
+ t.equal(bl.slice(0, 10).toString('ascii'), 'abcdefghij')
98
+ t.equal(bl.slice(3, 10).toString('ascii'), 'defghij')
99
+ t.equal(bl.slice(3, 6).toString('ascii'), 'def')
100
+ t.equal(bl.slice(3, 8).toString('ascii'), 'defgh')
101
+ t.equal(bl.slice(5, 10).toString('ascii'), 'fghij')
102
+ t.equal(bl.slice(-7, -4).toString('ascii'), 'def')
103
+
104
+ t.end()
105
+ })
106
+
107
+ tape('multiple bytes from multiple buffer lists', function (t) {
108
+ const bl = new BufferList()
109
+
110
+ bl.append(new BufferList([Buffer.from('abcd'), Buffer.from('efg')]))
111
+ bl.append(new BufferList([Buffer.from('hi'), Buffer.from('j')]))
112
+
113
+ t.equal(bl.length, 10)
114
+
115
+ t.equal(bl.slice(0, 10).toString('ascii'), 'abcdefghij')
116
+
117
+ t.equal(bl.slice(3, 10).toString('ascii'), 'defghij')
118
+ t.equal(bl.slice(3, 6).toString('ascii'), 'def')
119
+ t.equal(bl.slice(3, 8).toString('ascii'), 'defgh')
120
+ t.equal(bl.slice(5, 10).toString('ascii'), 'fghij')
121
+
122
+ t.end()
123
+ })
124
+
125
+ // same data as previous test, just using nested constructors
126
+ tape('multiple bytes from crazy nested buffer lists', function (t) {
127
+ const bl = new BufferList()
128
+
129
+ bl.append(new BufferList([
130
+ new BufferList([
131
+ new BufferList(Buffer.from('abc')),
132
+ Buffer.from('d'),
133
+ new BufferList(Buffer.from('efg'))
134
+ ]),
135
+ new BufferList([Buffer.from('hi')]),
136
+ new BufferList(Buffer.from('j'))
137
+ ]))
138
+
139
+ t.equal(bl.length, 10)
140
+
141
+ t.equal(bl.slice(0, 10).toString('ascii'), 'abcdefghij')
142
+
143
+ t.equal(bl.slice(3, 10).toString('ascii'), 'defghij')
144
+ t.equal(bl.slice(3, 6).toString('ascii'), 'def')
145
+ t.equal(bl.slice(3, 8).toString('ascii'), 'defgh')
146
+ t.equal(bl.slice(5, 10).toString('ascii'), 'fghij')
147
+
148
+ t.end()
149
+ })
150
+
151
+ tape('append accepts arrays of Buffers', function (t) {
152
+ const bl = new BufferList()
153
+
154
+ bl.append(Buffer.from('abc'))
155
+ bl.append([Buffer.from('def')])
156
+ bl.append([Buffer.from('ghi'), Buffer.from('jkl')])
157
+ bl.append([Buffer.from('mnop'), Buffer.from('qrstu'), Buffer.from('vwxyz')])
158
+ t.equal(bl.length, 26)
159
+ t.equal(bl.slice().toString('ascii'), 'abcdefghijklmnopqrstuvwxyz')
160
+
161
+ t.end()
162
+ })
163
+
164
+ tape('append accepts arrays of Uint8Arrays', function (t) {
165
+ const bl = new BufferList()
166
+
167
+ bl.append(new Uint8Array([97, 98, 99]))
168
+ bl.append([Uint8Array.from([100, 101, 102])])
169
+ bl.append([new Uint8Array([103, 104, 105]), new Uint8Array([106, 107, 108])])
170
+ bl.append([new Uint8Array([109, 110, 111, 112]), new Uint8Array([113, 114, 115, 116, 117]), new Uint8Array([118, 119, 120, 121, 122])])
171
+ t.equal(bl.length, 26)
172
+ t.equal(bl.slice().toString('ascii'), 'abcdefghijklmnopqrstuvwxyz')
173
+
174
+ t.end()
175
+ })
176
+
177
+ tape('append accepts arrays of BufferLists', function (t) {
178
+ const bl = new BufferList()
179
+
180
+ bl.append(Buffer.from('abc'))
181
+ bl.append([new BufferList('def')])
182
+ bl.append(new BufferList([Buffer.from('ghi'), new BufferList('jkl')]))
183
+ bl.append([Buffer.from('mnop'), new BufferList([Buffer.from('qrstu'), Buffer.from('vwxyz')])])
184
+ t.equal(bl.length, 26)
185
+ t.equal(bl.slice().toString('ascii'), 'abcdefghijklmnopqrstuvwxyz')
186
+
187
+ t.end()
188
+ })
189
+
190
+ tape('append chainable', function (t) {
191
+ const bl = new BufferList()
192
+
193
+ t.ok(bl.append(Buffer.from('abcd')) === bl)
194
+ t.ok(bl.append([Buffer.from('abcd')]) === bl)
195
+ t.ok(bl.append(new BufferList(Buffer.from('abcd'))) === bl)
196
+ t.ok(bl.append([new BufferList(Buffer.from('abcd'))]) === bl)
197
+
198
+ t.end()
199
+ })
200
+
201
+ tape('append chainable (test results)', function (t) {
202
+ const bl = new BufferList('abc')
203
+ .append([new BufferList('def')])
204
+ .append(new BufferList([Buffer.from('ghi'), new BufferList('jkl')]))
205
+ .append([Buffer.from('mnop'), new BufferList([Buffer.from('qrstu'), Buffer.from('vwxyz')])])
206
+
207
+ t.equal(bl.length, 26)
208
+ t.equal(bl.slice().toString('ascii'), 'abcdefghijklmnopqrstuvwxyz')
209
+
210
+ t.end()
211
+ })
212
+
213
+ tape('consuming from multiple buffers', function (t) {
214
+ const bl = new BufferList()
215
+
216
+ bl.append(Buffer.from('abcd'))
217
+ bl.append(Buffer.from('efg'))
218
+ bl.append(Buffer.from('hi'))
219
+ bl.append(Buffer.from('j'))
220
+
221
+ t.equal(bl.length, 10)
222
+
223
+ t.equal(bl.slice(0, 10).toString('ascii'), 'abcdefghij')
224
+
225
+ bl.consume(3)
226
+ t.equal(bl.length, 7)
227
+ t.equal(bl.slice(0, 7).toString('ascii'), 'defghij')
228
+
229
+ bl.consume(2)
230
+ t.equal(bl.length, 5)
231
+ t.equal(bl.slice(0, 5).toString('ascii'), 'fghij')
232
+
233
+ bl.consume(1)
234
+ t.equal(bl.length, 4)
235
+ t.equal(bl.slice(0, 4).toString('ascii'), 'ghij')
236
+
237
+ bl.consume(1)
238
+ t.equal(bl.length, 3)
239
+ t.equal(bl.slice(0, 3).toString('ascii'), 'hij')
240
+
241
+ bl.consume(2)
242
+ t.equal(bl.length, 1)
243
+ t.equal(bl.slice(0, 1).toString('ascii'), 'j')
244
+
245
+ t.end()
246
+ })
247
+
248
+ tape('complete consumption', function (t) {
249
+ const bl = new BufferList()
250
+
251
+ bl.append(Buffer.from('a'))
252
+ bl.append(Buffer.from('b'))
253
+
254
+ bl.consume(2)
255
+
256
+ t.equal(bl.length, 0)
257
+ t.equal(bl._bufs.length, 0)
258
+
259
+ t.end()
260
+ })
261
+
262
+ tape('test readUInt8 / readInt8', function (t) {
263
+ const buf1 = Buffer.alloc(1)
264
+ const buf2 = Buffer.alloc(3)
265
+ const buf3 = Buffer.alloc(3)
266
+ const bl = new BufferList()
267
+
268
+ buf2[1] = 0x3
269
+ buf2[2] = 0x4
270
+ buf3[0] = 0x23
271
+ buf3[1] = 0x42
272
+
273
+ bl.append(buf1)
274
+ bl.append(buf2)
275
+ bl.append(buf3)
276
+
277
+ t.equal(bl.readUInt8(2), 0x3)
278
+ t.equal(bl.readInt8(2), 0x3)
279
+ t.equal(bl.readUInt8(3), 0x4)
280
+ t.equal(bl.readInt8(3), 0x4)
281
+ t.equal(bl.readUInt8(4), 0x23)
282
+ t.equal(bl.readInt8(4), 0x23)
283
+ t.equal(bl.readUInt8(5), 0x42)
284
+ t.equal(bl.readInt8(5), 0x42)
285
+
286
+ t.end()
287
+ })
288
+
289
+ tape('test readUInt16LE / readUInt16BE / readInt16LE / readInt16BE', function (t) {
290
+ const buf1 = Buffer.alloc(1)
291
+ const buf2 = Buffer.alloc(3)
292
+ const buf3 = Buffer.alloc(3)
293
+ const bl = new BufferList()
294
+
295
+ buf2[1] = 0x3
296
+ buf2[2] = 0x4
297
+ buf3[0] = 0x23
298
+ buf3[1] = 0x42
299
+
300
+ bl.append(buf1)
301
+ bl.append(buf2)
302
+ bl.append(buf3)
303
+
304
+ t.equal(bl.readUInt16BE(2), 0x0304)
305
+ t.equal(bl.readUInt16LE(2), 0x0403)
306
+ t.equal(bl.readInt16BE(2), 0x0304)
307
+ t.equal(bl.readInt16LE(2), 0x0403)
308
+ t.equal(bl.readUInt16BE(3), 0x0423)
309
+ t.equal(bl.readUInt16LE(3), 0x2304)
310
+ t.equal(bl.readInt16BE(3), 0x0423)
311
+ t.equal(bl.readInt16LE(3), 0x2304)
312
+ t.equal(bl.readUInt16BE(4), 0x2342)
313
+ t.equal(bl.readUInt16LE(4), 0x4223)
314
+ t.equal(bl.readInt16BE(4), 0x2342)
315
+ t.equal(bl.readInt16LE(4), 0x4223)
316
+
317
+ t.end()
318
+ })
319
+
320
+ tape('test readUInt32LE / readUInt32BE / readInt32LE / readInt32BE', function (t) {
321
+ const buf1 = Buffer.alloc(1)
322
+ const buf2 = Buffer.alloc(3)
323
+ const buf3 = Buffer.alloc(3)
324
+ const bl = new BufferList()
325
+
326
+ buf2[1] = 0x3
327
+ buf2[2] = 0x4
328
+ buf3[0] = 0x23
329
+ buf3[1] = 0x42
330
+
331
+ bl.append(buf1)
332
+ bl.append(buf2)
333
+ bl.append(buf3)
334
+
335
+ t.equal(bl.readUInt32BE(2), 0x03042342)
336
+ t.equal(bl.readUInt32LE(2), 0x42230403)
337
+ t.equal(bl.readInt32BE(2), 0x03042342)
338
+ t.equal(bl.readInt32LE(2), 0x42230403)
339
+
340
+ t.end()
341
+ })
342
+
343
+ tape('test readUIntLE / readUIntBE / readIntLE / readIntBE', function (t) {
344
+ const buf1 = Buffer.alloc(1)
345
+ const buf2 = Buffer.alloc(3)
346
+ const buf3 = Buffer.alloc(3)
347
+ const bl = new BufferList()
348
+
349
+ buf2[0] = 0x2
350
+ buf2[1] = 0x3
351
+ buf2[2] = 0x4
352
+ buf3[0] = 0x23
353
+ buf3[1] = 0x42
354
+ buf3[2] = 0x61
355
+
356
+ bl.append(buf1)
357
+ bl.append(buf2)
358
+ bl.append(buf3)
359
+
360
+ t.equal(bl.readUIntBE(1, 1), 0x02)
361
+ t.equal(bl.readUIntBE(1, 2), 0x0203)
362
+ t.equal(bl.readUIntBE(1, 3), 0x020304)
363
+ t.equal(bl.readUIntBE(1, 4), 0x02030423)
364
+ t.equal(bl.readUIntBE(1, 5), 0x0203042342)
365
+ t.equal(bl.readUIntBE(1, 6), 0x020304234261)
366
+ t.equal(bl.readUIntLE(1, 1), 0x02)
367
+ t.equal(bl.readUIntLE(1, 2), 0x0302)
368
+ t.equal(bl.readUIntLE(1, 3), 0x040302)
369
+ t.equal(bl.readUIntLE(1, 4), 0x23040302)
370
+ t.equal(bl.readUIntLE(1, 5), 0x4223040302)
371
+ t.equal(bl.readUIntLE(1, 6), 0x614223040302)
372
+ t.equal(bl.readIntBE(1, 1), 0x02)
373
+ t.equal(bl.readIntBE(1, 2), 0x0203)
374
+ t.equal(bl.readIntBE(1, 3), 0x020304)
375
+ t.equal(bl.readIntBE(1, 4), 0x02030423)
376
+ t.equal(bl.readIntBE(1, 5), 0x0203042342)
377
+ t.equal(bl.readIntBE(1, 6), 0x020304234261)
378
+ t.equal(bl.readIntLE(1, 1), 0x02)
379
+ t.equal(bl.readIntLE(1, 2), 0x0302)
380
+ t.equal(bl.readIntLE(1, 3), 0x040302)
381
+ t.equal(bl.readIntLE(1, 4), 0x23040302)
382
+ t.equal(bl.readIntLE(1, 5), 0x4223040302)
383
+ t.equal(bl.readIntLE(1, 6), 0x614223040302)
384
+
385
+ t.end()
386
+ })
387
+
388
+ tape('test readFloatLE / readFloatBE', function (t) {
389
+ const buf1 = Buffer.alloc(1)
390
+ const buf2 = Buffer.alloc(3)
391
+ const buf3 = Buffer.alloc(3)
392
+ const bl = new BufferList()
393
+
394
+ buf2[1] = 0x00
395
+ buf2[2] = 0x00
396
+ buf3[0] = 0x80
397
+ buf3[1] = 0x3f
398
+
399
+ bl.append(buf1)
400
+ bl.append(buf2)
401
+ bl.append(buf3)
402
+
403
+ t.equal(bl.readFloatLE(2), 0x01)
404
+
405
+ t.end()
406
+ })
407
+
408
+ tape('test readDoubleLE / readDoubleBE', function (t) {
409
+ const buf1 = Buffer.alloc(1)
410
+ const buf2 = Buffer.alloc(3)
411
+ const buf3 = Buffer.alloc(10)
412
+ const bl = new BufferList()
413
+
414
+ buf2[1] = 0x55
415
+ buf2[2] = 0x55
416
+ buf3[0] = 0x55
417
+ buf3[1] = 0x55
418
+ buf3[2] = 0x55
419
+ buf3[3] = 0x55
420
+ buf3[4] = 0xd5
421
+ buf3[5] = 0x3f
422
+
423
+ bl.append(buf1)
424
+ bl.append(buf2)
425
+ bl.append(buf3)
426
+
427
+ t.equal(bl.readDoubleLE(2), 0.3333333333333333)
428
+
429
+ t.end()
430
+ })
431
+
432
+ tape('test toString', function (t) {
433
+ const bl = new BufferList()
434
+
435
+ bl.append(Buffer.from('abcd'))
436
+ bl.append(Buffer.from('efg'))
437
+ bl.append(Buffer.from('hi'))
438
+ bl.append(Buffer.from('j'))
439
+
440
+ t.equal(bl.toString('ascii', 0, 10), 'abcdefghij')
441
+ t.equal(bl.toString('ascii', 3, 10), 'defghij')
442
+ t.equal(bl.toString('ascii', 3, 6), 'def')
443
+ t.equal(bl.toString('ascii', 3, 8), 'defgh')
444
+ t.equal(bl.toString('ascii', 5, 10), 'fghij')
445
+
446
+ t.end()
447
+ })
448
+
449
+ tape('test toString encoding', function (t) {
450
+ const bl = new BufferList()
451
+ const b = Buffer.from('abcdefghij\xff\x00')
452
+
453
+ bl.append(Buffer.from('abcd'))
454
+ bl.append(Buffer.from('efg'))
455
+ bl.append(Buffer.from('hi'))
456
+ bl.append(Buffer.from('j'))
457
+ bl.append(Buffer.from('\xff\x00'))
458
+
459
+ encodings.forEach(function (enc) {
460
+ t.equal(bl.toString(enc), b.toString(enc), enc)
461
+ })
462
+
463
+ t.end()
464
+ })
465
+
466
+ tape('uninitialized memory', function (t) {
467
+ const secret = crypto.randomBytes(256)
468
+ for (let i = 0; i < 1e6; i++) {
469
+ const clone = Buffer.from(secret)
470
+ const bl = new BufferList()
471
+ bl.append(Buffer.from('a'))
472
+ bl.consume(-1024)
473
+ const buf = bl.slice(1)
474
+ if (buf.indexOf(clone) !== -1) {
475
+ t.fail(`Match (at ${i})`)
476
+ break
477
+ }
478
+ }
479
+ t.end()
480
+ })
481
+
482
+ !process.browser && tape('test stream', function (t) {
483
+ const random = crypto.randomBytes(65534)
484
+
485
+ const bl = new BufferList((err, buf) => {
486
+ t.ok(Buffer.isBuffer(buf))
487
+ t.ok(err === null)
488
+ t.ok(random.equals(bl.slice()))
489
+ t.ok(random.equals(buf.slice()))
490
+
491
+ bl.pipe(fs.createWriteStream('/tmp/bl_test_rnd_out.dat'))
492
+ .on('close', function () {
493
+ const rndhash = crypto.createHash('md5').update(random).digest('hex')
494
+ const md5sum = crypto.createHash('md5')
495
+ const s = fs.createReadStream('/tmp/bl_test_rnd_out.dat')
496
+
497
+ s.on('data', md5sum.update.bind(md5sum))
498
+ s.on('end', function () {
499
+ t.equal(rndhash, md5sum.digest('hex'), 'woohoo! correct hash!')
500
+ t.end()
501
+ })
502
+ })
503
+ })
504
+
505
+ fs.writeFileSync('/tmp/bl_test_rnd.dat', random)
506
+ fs.createReadStream('/tmp/bl_test_rnd.dat').pipe(bl)
507
+ })
508
+
509
+ tape('instantiation with Buffer', function (t) {
510
+ const buf = crypto.randomBytes(1024)
511
+ const buf2 = crypto.randomBytes(1024)
512
+ let b = BufferList(buf)
513
+
514
+ t.equal(buf.toString('hex'), b.slice().toString('hex'), 'same buffer')
515
+ b = BufferList([buf, buf2])
516
+ t.equal(b.slice().toString('hex'), Buffer.concat([buf, buf2]).toString('hex'), 'same buffer')
517
+
518
+ t.end()
519
+ })
520
+
521
+ tape('test String appendage', function (t) {
522
+ const bl = new BufferList()
523
+ const b = Buffer.from('abcdefghij\xff\x00')
524
+
525
+ bl.append('abcd')
526
+ bl.append('efg')
527
+ bl.append('hi')
528
+ bl.append('j')
529
+ bl.append('\xff\x00')
530
+
531
+ encodings.forEach(function (enc) {
532
+ t.equal(bl.toString(enc), b.toString(enc))
533
+ })
534
+
535
+ t.end()
536
+ })
537
+
538
+ tape('test Number appendage', function (t) {
539
+ const bl = new BufferList()
540
+ const b = Buffer.from('1234567890')
541
+
542
+ bl.append(1234)
543
+ bl.append(567)
544
+ bl.append(89)
545
+ bl.append(0)
546
+
547
+ encodings.forEach(function (enc) {
548
+ t.equal(bl.toString(enc), b.toString(enc))
549
+ })
550
+
551
+ t.end()
552
+ })
553
+
554
+ tape('write nothing, should get empty buffer', function (t) {
555
+ t.plan(3)
556
+ BufferList(function (err, data) {
557
+ t.notOk(err, 'no error')
558
+ t.ok(Buffer.isBuffer(data), 'got a buffer')
559
+ t.equal(0, data.length, 'got a zero-length buffer')
560
+ t.end()
561
+ }).end()
562
+ })
563
+
564
+ tape('unicode string', function (t) {
565
+ t.plan(2)
566
+
567
+ const inp1 = '\u2600'
568
+ const inp2 = '\u2603'
569
+ const exp = inp1 + ' and ' + inp2
570
+ const bl = BufferList()
571
+
572
+ bl.write(inp1)
573
+ bl.write(' and ')
574
+ bl.write(inp2)
575
+ t.equal(exp, bl.toString())
576
+ t.equal(Buffer.from(exp).toString('hex'), bl.toString('hex'))
577
+ })
578
+
579
+ tape('should emit finish', function (t) {
580
+ const source = BufferList()
581
+ const dest = BufferList()
582
+
583
+ source.write('hello')
584
+ source.pipe(dest)
585
+
586
+ dest.on('finish', function () {
587
+ t.equal(dest.toString('utf8'), 'hello')
588
+ t.end()
589
+ })
590
+ })
591
+
592
+ tape('basic copy', function (t) {
593
+ const buf = crypto.randomBytes(1024)
594
+ const buf2 = Buffer.alloc(1024)
595
+ const b = BufferList(buf)
596
+
597
+ b.copy(buf2)
598
+ t.equal(b.slice().toString('hex'), buf2.toString('hex'), 'same buffer')
599
+
600
+ t.end()
601
+ })
602
+
603
+ tape('copy after many appends', function (t) {
604
+ const buf = crypto.randomBytes(512)
605
+ const buf2 = Buffer.alloc(1024)
606
+ const b = BufferList(buf)
607
+
608
+ b.append(buf)
609
+ b.copy(buf2)
610
+ t.equal(b.slice().toString('hex'), buf2.toString('hex'), 'same buffer')
611
+
612
+ t.end()
613
+ })
614
+
615
+ tape('copy at a precise position', function (t) {
616
+ const buf = crypto.randomBytes(1004)
617
+ const buf2 = Buffer.alloc(1024)
618
+ const b = BufferList(buf)
619
+
620
+ b.copy(buf2, 20)
621
+ t.equal(b.slice().toString('hex'), buf2.slice(20).toString('hex'), 'same buffer')
622
+
623
+ t.end()
624
+ })
625
+
626
+ tape('copy starting from a precise location', function (t) {
627
+ const buf = crypto.randomBytes(10)
628
+ const buf2 = Buffer.alloc(5)
629
+ const b = BufferList(buf)
630
+
631
+ b.copy(buf2, 0, 5)
632
+ t.equal(b.slice(5).toString('hex'), buf2.toString('hex'), 'same buffer')
633
+
634
+ t.end()
635
+ })
636
+
637
+ tape('copy in an interval', function (t) {
638
+ const rnd = crypto.randomBytes(10)
639
+ const b = BufferList(rnd) // put the random bytes there
640
+ const actual = Buffer.alloc(3)
641
+ const expected = Buffer.alloc(3)
642
+
643
+ rnd.copy(expected, 0, 5, 8)
644
+ b.copy(actual, 0, 5, 8)
645
+
646
+ t.equal(actual.toString('hex'), expected.toString('hex'), 'same buffer')
647
+
648
+ t.end()
649
+ })
650
+
651
+ tape('copy an interval between two buffers', function (t) {
652
+ const buf = crypto.randomBytes(10)
653
+ const buf2 = Buffer.alloc(10)
654
+ const b = BufferList(buf)
655
+
656
+ b.append(buf)
657
+ b.copy(buf2, 0, 5, 15)
658
+
659
+ t.equal(b.slice(5, 15).toString('hex'), buf2.toString('hex'), 'same buffer')
660
+
661
+ t.end()
662
+ })
663
+
664
+ tape('shallow slice across buffer boundaries', function (t) {
665
+ const bl = new BufferList(['First', 'Second', 'Third'])
666
+
667
+ t.equal(bl.shallowSlice(3, 13).toString(), 'stSecondTh')
668
+
669
+ t.end()
670
+ })
671
+
672
+ tape('shallow slice within single buffer', function (t) {
673
+ t.plan(2)
674
+
675
+ const bl = new BufferList(['First', 'Second', 'Third'])
676
+
677
+ t.equal(bl.shallowSlice(5, 10).toString(), 'Secon')
678
+ t.equal(bl.shallowSlice(7, 10).toString(), 'con')
679
+
680
+ t.end()
681
+ })
682
+
683
+ tape('shallow slice single buffer', function (t) {
684
+ t.plan(3)
685
+
686
+ const bl = new BufferList(['First', 'Second', 'Third'])
687
+
688
+ t.equal(bl.shallowSlice(0, 5).toString(), 'First')
689
+ t.equal(bl.shallowSlice(5, 11).toString(), 'Second')
690
+ t.equal(bl.shallowSlice(11, 16).toString(), 'Third')
691
+ })
692
+
693
+ tape('shallow slice with negative or omitted indices', function (t) {
694
+ t.plan(4)
695
+
696
+ const bl = new BufferList(['First', 'Second', 'Third'])
697
+
698
+ t.equal(bl.shallowSlice().toString(), 'FirstSecondThird')
699
+ t.equal(bl.shallowSlice(5).toString(), 'SecondThird')
700
+ t.equal(bl.shallowSlice(5, -3).toString(), 'SecondTh')
701
+ t.equal(bl.shallowSlice(-8).toString(), 'ondThird')
702
+ })
703
+
704
+ tape('shallow slice does not make a copy', function (t) {
705
+ t.plan(1)
706
+
707
+ const buffers = [Buffer.from('First'), Buffer.from('Second'), Buffer.from('Third')]
708
+ const bl = (new BufferList(buffers)).shallowSlice(5, -3)
709
+
710
+ buffers[1].fill('h')
711
+ buffers[2].fill('h')
712
+
713
+ t.equal(bl.toString(), 'hhhhhhhh')
714
+ })
715
+
716
+ tape('shallow slice with 0 length', function (t) {
717
+ t.plan(1)
718
+
719
+ const buffers = [Buffer.from('First'), Buffer.from('Second'), Buffer.from('Third')]
720
+ const bl = (new BufferList(buffers)).shallowSlice(0, 0)
721
+
722
+ t.equal(bl.length, 0)
723
+ })
724
+
725
+ tape('shallow slice with 0 length from middle', function (t) {
726
+ t.plan(1)
727
+
728
+ const buffers = [Buffer.from('First'), Buffer.from('Second'), Buffer.from('Third')]
729
+ const bl = (new BufferList(buffers)).shallowSlice(10, 10)
730
+
731
+ t.equal(bl.length, 0)
732
+ })
733
+
734
+ tape('duplicate', function (t) {
735
+ t.plan(2)
736
+
737
+ const bl = new BufferList('abcdefghij\xff\x00')
738
+ const dup = bl.duplicate()
739
+
740
+ t.equal(bl.prototype, dup.prototype)
741
+ t.equal(bl.toString('hex'), dup.toString('hex'))
742
+ })
743
+
744
+ tape('destroy no pipe', function (t) {
745
+ t.plan(2)
746
+
747
+ const bl = new BufferList('alsdkfja;lsdkfja;lsdk')
748
+
749
+ bl.destroy()
750
+
751
+ t.equal(bl._bufs.length, 0)
752
+ t.equal(bl.length, 0)
753
+ })
754
+
755
+ tape('destroy with error', function (t) {
756
+ t.plan(3)
757
+
758
+ const bl = new BufferList('alsdkfja;lsdkfja;lsdk')
759
+ const err = new Error('kaboom')
760
+
761
+ bl.destroy(err)
762
+ bl.on('error', function (_err) {
763
+ t.equal(_err, err)
764
+ })
765
+
766
+ t.equal(bl._bufs.length, 0)
767
+ t.equal(bl.length, 0)
768
+ })
769
+
770
+ !process.browser && tape('destroy with pipe before read end', function (t) {
771
+ t.plan(2)
772
+
773
+ const bl = new BufferList()
774
+ fs.createReadStream(path.join(__dirname, '/test.js'))
775
+ .pipe(bl)
776
+
777
+ bl.destroy()
778
+
779
+ t.equal(bl._bufs.length, 0)
780
+ t.equal(bl.length, 0)
781
+ })
782
+
783
+ !process.browser && tape('destroy with pipe before read end with race', function (t) {
784
+ t.plan(2)
785
+
786
+ const bl = new BufferList()
787
+
788
+ fs.createReadStream(path.join(__dirname, '/test.js'))
789
+ .pipe(bl)
790
+
791
+ setTimeout(function () {
792
+ bl.destroy()
793
+ setTimeout(function () {
794
+ t.equal(bl._bufs.length, 0)
795
+ t.equal(bl.length, 0)
796
+ }, 500)
797
+ }, 500)
798
+ })
799
+
800
+ !process.browser && tape('destroy with pipe after read end', function (t) {
801
+ t.plan(2)
802
+
803
+ const bl = new BufferList()
804
+
805
+ fs.createReadStream(path.join(__dirname, '/test.js'))
806
+ .on('end', onEnd)
807
+ .pipe(bl)
808
+
809
+ function onEnd () {
810
+ bl.destroy()
811
+
812
+ t.equal(bl._bufs.length, 0)
813
+ t.equal(bl.length, 0)
814
+ }
815
+ })
816
+
817
+ !process.browser && tape('destroy with pipe while writing to a destination', function (t) {
818
+ t.plan(4)
819
+
820
+ const bl = new BufferList()
821
+ const ds = new BufferList()
822
+
823
+ fs.createReadStream(path.join(__dirname, '/test.js'))
824
+ .on('end', onEnd)
825
+ .pipe(bl)
826
+
827
+ function onEnd () {
828
+ bl.pipe(ds)
829
+
830
+ setTimeout(function () {
831
+ bl.destroy()
832
+
833
+ t.equals(bl._bufs.length, 0)
834
+ t.equals(bl.length, 0)
835
+
836
+ ds.destroy()
837
+
838
+ t.equals(bl._bufs.length, 0)
839
+ t.equals(bl.length, 0)
840
+ }, 100)
841
+ }
842
+ })
843
+
844
+ !process.browser && tape('handle error', function (t) {
845
+ t.plan(2)
846
+
847
+ fs.createReadStream('/does/not/exist').pipe(BufferList(function (err, data) {
848
+ t.ok(err instanceof Error, 'has error')
849
+ t.notOk(data, 'no data')
850
+ }))
851
+ })