plugin-data-source-mssql 2.0.3 → 2.0.5

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 (410) hide show
  1. package/dist/client/index.js +1 -1
  2. package/dist/externalVersion.js +6 -6
  3. package/dist/server/data-source/MssqlExternalDataSource.js +114 -30
  4. package/dist/server/data-source/MssqlIntrospector.js +109 -24
  5. package/package.json +1 -1
  6. package/dist/node_modules/tedious/245.index.js +0 -741
  7. package/dist/node_modules/tedious/LICENSE +0 -21
  8. package/dist/node_modules/tedious/appveyor.yml +0 -67
  9. package/dist/node_modules/tedious/benchmarks/bulk-load/iterable.js +0 -61
  10. package/dist/node_modules/tedious/benchmarks/common.js +0 -287
  11. package/dist/node_modules/tedious/benchmarks/connection/open.js +0 -26
  12. package/dist/node_modules/tedious/benchmarks/package-lock.json +0 -21173
  13. package/dist/node_modules/tedious/benchmarks/package.json +0 -11
  14. package/dist/node_modules/tedious/benchmarks/query/call-tvp.js +0 -105
  15. package/dist/node_modules/tedious/benchmarks/query/insert-varbinary.js +0 -46
  16. package/dist/node_modules/tedious/benchmarks/query/select-many-rows.js +0 -63
  17. package/dist/node_modules/tedious/benchmarks/query/select-nvarchar.js +0 -50
  18. package/dist/node_modules/tedious/benchmarks/query/select-varbinary.js +0 -50
  19. package/dist/node_modules/tedious/benchmarks/request/rpcrequest-payload-tvp.js +0 -45
  20. package/dist/node_modules/tedious/benchmarks/request/rpcrequest-payload-varbinary.js +0 -37
  21. package/dist/node_modules/tedious/benchmarks/token-parser/colmetadata-token.js +0 -27
  22. package/dist/node_modules/tedious/benchmarks/token-parser/done-token.js +0 -28
  23. package/dist/node_modules/tedious/benchmarks/token-parser/simple-tokens.js +0 -363
  24. package/dist/node_modules/tedious/lib/all-headers.d.ts +0 -2
  25. package/dist/node_modules/tedious/lib/all-headers.js +0 -24
  26. package/dist/node_modules/tedious/lib/always-encrypted/aead-aes-256-cbc-hmac-algorithm.js +0 -82
  27. package/dist/node_modules/tedious/lib/always-encrypted/aead-aes-256-cbc-hmac-encryption-key.js +0 -55
  28. package/dist/node_modules/tedious/lib/always-encrypted/cek-entry.d.ts +0 -11
  29. package/dist/node_modules/tedious/lib/always-encrypted/cek-entry.js +0 -42
  30. package/dist/node_modules/tedious/lib/always-encrypted/get-parameter-encryption-metadata.js +0 -90
  31. package/dist/node_modules/tedious/lib/always-encrypted/key-crypto.js +0 -94
  32. package/dist/node_modules/tedious/lib/always-encrypted/keystore-provider-azure-key-vault.d.ts +0 -21
  33. package/dist/node_modules/tedious/lib/always-encrypted/keystore-provider-azure-key-vault.js +0 -247
  34. package/dist/node_modules/tedious/lib/always-encrypted/symmetric-key-cache.js +0 -36
  35. package/dist/node_modules/tedious/lib/always-encrypted/symmetric-key.js +0 -25
  36. package/dist/node_modules/tedious/lib/always-encrypted/types.d.ts +0 -73
  37. package/dist/node_modules/tedious/lib/always-encrypted/types.js +0 -48
  38. package/dist/node_modules/tedious/lib/always-encrypted/utils.js +0 -23
  39. package/dist/node_modules/tedious/lib/bulk-load-payload.d.ts +0 -8
  40. package/dist/node_modules/tedious/lib/bulk-load-payload.js +0 -23
  41. package/dist/node_modules/tedious/lib/bulk-load.d.ts +0 -275
  42. package/dist/node_modules/tedious/lib/bulk-load.js +0 -516
  43. package/dist/node_modules/tedious/lib/collation.d.ts +0 -28
  44. package/dist/node_modules/tedious/lib/collation.js +0 -348
  45. package/dist/node_modules/tedious/lib/connection.d.ts +0 -1310
  46. package/dist/node_modules/tedious/lib/connection.js +0 -2730
  47. package/dist/node_modules/tedious/lib/connector.d.ts +0 -18
  48. package/dist/node_modules/tedious/lib/connector.js +0 -150
  49. package/dist/node_modules/tedious/lib/data-type.d.ts +0 -455
  50. package/dist/node_modules/tedious/lib/data-type.js +0 -428
  51. package/dist/node_modules/tedious/lib/data-types/bigint.d.ts +0 -3
  52. package/dist/node_modules/tedious/lib/data-types/bigint.js +0 -53
  53. package/dist/node_modules/tedious/lib/data-types/binary.d.ts +0 -5
  54. package/dist/node_modules/tedious/lib/data-types/binary.js +0 -67
  55. package/dist/node_modules/tedious/lib/data-types/bit.d.ts +0 -3
  56. package/dist/node_modules/tedious/lib/data-types/bit.js +0 -46
  57. package/dist/node_modules/tedious/lib/data-types/bitn.d.ts +0 -3
  58. package/dist/node_modules/tedious/lib/data-types/bitn.js +0 -29
  59. package/dist/node_modules/tedious/lib/data-types/char.d.ts +0 -5
  60. package/dist/node_modules/tedious/lib/data-types/char.js +0 -86
  61. package/dist/node_modules/tedious/lib/data-types/date.d.ts +0 -3
  62. package/dist/node_modules/tedious/lib/data-types/date.js +0 -72
  63. package/dist/node_modules/tedious/lib/data-types/datetime.d.ts +0 -3
  64. package/dist/node_modules/tedious/lib/data-types/datetime.js +0 -93
  65. package/dist/node_modules/tedious/lib/data-types/datetime2.d.ts +0 -5
  66. package/dist/node_modules/tedious/lib/data-types/datetime2.js +0 -118
  67. package/dist/node_modules/tedious/lib/data-types/datetimen.d.ts +0 -3
  68. package/dist/node_modules/tedious/lib/data-types/datetimen.js +0 -29
  69. package/dist/node_modules/tedious/lib/data-types/datetimeoffset.d.ts +0 -5
  70. package/dist/node_modules/tedious/lib/data-types/datetimeoffset.js +0 -111
  71. package/dist/node_modules/tedious/lib/data-types/decimal.d.ts +0 -6
  72. package/dist/node_modules/tedious/lib/data-types/decimal.js +0 -107
  73. package/dist/node_modules/tedious/lib/data-types/decimaln.d.ts +0 -3
  74. package/dist/node_modules/tedious/lib/data-types/decimaln.js +0 -29
  75. package/dist/node_modules/tedious/lib/data-types/float.d.ts +0 -3
  76. package/dist/node_modules/tedious/lib/data-types/float.js +0 -47
  77. package/dist/node_modules/tedious/lib/data-types/floatn.d.ts +0 -3
  78. package/dist/node_modules/tedious/lib/data-types/floatn.js +0 -29
  79. package/dist/node_modules/tedious/lib/data-types/image.d.ts +0 -3
  80. package/dist/node_modules/tedious/lib/data-types/image.js +0 -56
  81. package/dist/node_modules/tedious/lib/data-types/int.d.ts +0 -3
  82. package/dist/node_modules/tedious/lib/data-types/int.js +0 -53
  83. package/dist/node_modules/tedious/lib/data-types/intn.d.ts +0 -3
  84. package/dist/node_modules/tedious/lib/data-types/intn.js +0 -29
  85. package/dist/node_modules/tedious/lib/data-types/money.d.ts +0 -3
  86. package/dist/node_modules/tedious/lib/data-types/money.js +0 -59
  87. package/dist/node_modules/tedious/lib/data-types/moneyn.d.ts +0 -3
  88. package/dist/node_modules/tedious/lib/data-types/moneyn.js +0 -29
  89. package/dist/node_modules/tedious/lib/data-types/nchar.d.ts +0 -5
  90. package/dist/node_modules/tedious/lib/data-types/nchar.js +0 -100
  91. package/dist/node_modules/tedious/lib/data-types/ntext.d.ts +0 -3
  92. package/dist/node_modules/tedious/lib/data-types/ntext.js +0 -60
  93. package/dist/node_modules/tedious/lib/data-types/null.d.ts +0 -3
  94. package/dist/node_modules/tedious/lib/data-types/null.js +0 -29
  95. package/dist/node_modules/tedious/lib/data-types/numeric.d.ts +0 -6
  96. package/dist/node_modules/tedious/lib/data-types/numeric.js +0 -106
  97. package/dist/node_modules/tedious/lib/data-types/numericn.d.ts +0 -3
  98. package/dist/node_modules/tedious/lib/data-types/numericn.js +0 -29
  99. package/dist/node_modules/tedious/lib/data-types/nvarchar.d.ts +0 -5
  100. package/dist/node_modules/tedious/lib/data-types/nvarchar.js +0 -133
  101. package/dist/node_modules/tedious/lib/data-types/real.d.ts +0 -3
  102. package/dist/node_modules/tedious/lib/data-types/real.js +0 -48
  103. package/dist/node_modules/tedious/lib/data-types/smalldatetime.d.ts +0 -3
  104. package/dist/node_modules/tedious/lib/data-types/smalldatetime.js +0 -83
  105. package/dist/node_modules/tedious/lib/data-types/smallint.d.ts +0 -3
  106. package/dist/node_modules/tedious/lib/data-types/smallint.js +0 -53
  107. package/dist/node_modules/tedious/lib/data-types/smallmoney.d.ts +0 -3
  108. package/dist/node_modules/tedious/lib/data-types/smallmoney.js +0 -51
  109. package/dist/node_modules/tedious/lib/data-types/sql-variant.d.ts +0 -3
  110. package/dist/node_modules/tedious/lib/data-types/sql-variant.js +0 -29
  111. package/dist/node_modules/tedious/lib/data-types/text.d.ts +0 -3
  112. package/dist/node_modules/tedious/lib/data-types/text.js +0 -69
  113. package/dist/node_modules/tedious/lib/data-types/time.d.ts +0 -3
  114. package/dist/node_modules/tedious/lib/data-types/time.js +0 -96
  115. package/dist/node_modules/tedious/lib/data-types/tinyint.d.ts +0 -3
  116. package/dist/node_modules/tedious/lib/data-types/tinyint.js +0 -53
  117. package/dist/node_modules/tedious/lib/data-types/tvp.d.ts +0 -3
  118. package/dist/node_modules/tedious/lib/data-types/tvp.js +0 -117
  119. package/dist/node_modules/tedious/lib/data-types/udt.d.ts +0 -3
  120. package/dist/node_modules/tedious/lib/data-types/udt.js +0 -29
  121. package/dist/node_modules/tedious/lib/data-types/uniqueidentifier.d.ts +0 -3
  122. package/dist/node_modules/tedious/lib/data-types/uniqueidentifier.js +0 -50
  123. package/dist/node_modules/tedious/lib/data-types/varbinary.d.ts +0 -5
  124. package/dist/node_modules/tedious/lib/data-types/varbinary.js +0 -119
  125. package/dist/node_modules/tedious/lib/data-types/varchar.d.ts +0 -5
  126. package/dist/node_modules/tedious/lib/data-types/varchar.js +0 -112
  127. package/dist/node_modules/tedious/lib/data-types/xml.d.ts +0 -3
  128. package/dist/node_modules/tedious/lib/data-types/xml.js +0 -29
  129. package/dist/node_modules/tedious/lib/debug.d.ts +0 -25
  130. package/dist/node_modules/tedious/lib/debug.js +0 -67
  131. package/dist/node_modules/tedious/lib/errors/abort-error.d.ts +0 -4
  132. package/dist/node_modules/tedious/lib/errors/abort-error.js +0 -15
  133. package/dist/node_modules/tedious/lib/errors/timeout-error.d.ts +0 -4
  134. package/dist/node_modules/tedious/lib/errors/timeout-error.js +0 -15
  135. package/dist/node_modules/tedious/lib/errors.d.ts +0 -17
  136. package/dist/node_modules/tedious/lib/errors.js +0 -23
  137. package/dist/node_modules/tedious/lib/guid-parser.d.ts +0 -3
  138. package/dist/node_modules/tedious/lib/guid-parser.js +0 -30
  139. package/dist/node_modules/tedious/lib/incoming-message-stream.d.ts +0 -19
  140. package/dist/node_modules/tedious/lib/incoming-message-stream.js +0 -97
  141. package/dist/node_modules/tedious/lib/instance-lookup.d.ts +0 -13
  142. package/dist/node_modules/tedious/lib/instance-lookup.js +0 -96
  143. package/dist/node_modules/tedious/lib/library.d.ts +0 -1
  144. package/dist/node_modules/tedious/lib/library.js +0 -8
  145. package/dist/node_modules/tedious/lib/login7-payload.d.ts +0 -51
  146. package/dist/node_modules/tedious/lib/login7-payload.js +0 -402
  147. package/dist/node_modules/tedious/lib/message-io.d.ts +0 -28
  148. package/dist/node_modules/tedious/lib/message-io.js +0 -153
  149. package/dist/node_modules/tedious/lib/message.d.ts +0 -11
  150. package/dist/node_modules/tedious/lib/message.js +0 -21
  151. package/dist/node_modules/tedious/lib/metadata-parser.d.ts +0 -48
  152. package/dist/node_modules/tedious/lib/metadata-parser.js +0 -380
  153. package/dist/node_modules/tedious/lib/ntlm-payload.d.ts +0 -23
  154. package/dist/node_modules/tedious/lib/ntlm-payload.js +0 -136
  155. package/dist/node_modules/tedious/lib/ntlm.d.ts +0 -4
  156. package/dist/node_modules/tedious/lib/ntlm.js +0 -72
  157. package/dist/node_modules/tedious/lib/outgoing-message-stream.d.ts +0 -15
  158. package/dist/node_modules/tedious/lib/outgoing-message-stream.js +0 -81
  159. package/dist/node_modules/tedious/lib/packet.d.ts +0 -33
  160. package/dist/node_modules/tedious/lib/packet.js +0 -191
  161. package/dist/node_modules/tedious/lib/prelogin-payload.d.ts +0 -61
  162. package/dist/node_modules/tedious/lib/prelogin-payload.js +0 -209
  163. package/dist/node_modules/tedious/lib/request.d.ts +0 -370
  164. package/dist/node_modules/tedious/lib/request.js +0 -387
  165. package/dist/node_modules/tedious/lib/rpcrequest-payload.d.ts +0 -16
  166. package/dist/node_modules/tedious/lib/rpcrequest-payload.js +0 -109
  167. package/dist/node_modules/tedious/lib/sender.d.ts +0 -5
  168. package/dist/node_modules/tedious/lib/sender.js +0 -83
  169. package/dist/node_modules/tedious/lib/special-stored-procedure.d.ts +0 -18
  170. package/dist/node_modules/tedious/lib/special-stored-procedure.js +0 -26
  171. package/dist/node_modules/tedious/lib/sqlbatch-payload.d.ts +0 -13
  172. package/dist/node_modules/tedious/lib/sqlbatch-payload.js +0 -34
  173. package/dist/node_modules/tedious/lib/tds-versions.d.ts +0 -6
  174. package/dist/node_modules/tedious/lib/tds-versions.js +0 -19
  175. package/dist/node_modules/tedious/lib/tedious.d.ts +0 -13
  176. package/dist/node_modules/tedious/lib/tedious.js +0 -249
  177. package/dist/node_modules/tedious/lib/token/colmetadata-token-parser.d.ts +0 -12
  178. package/dist/node_modules/tedious/lib/token/colmetadata-token-parser.js +0 -124
  179. package/dist/node_modules/tedious/lib/token/done-token-parser.d.ts +0 -6
  180. package/dist/node_modules/tedious/lib/token/done-token-parser.js +0 -76
  181. package/dist/node_modules/tedious/lib/token/env-change-token-parser.d.ts +0 -5
  182. package/dist/node_modules/tedious/lib/token/env-change-token-parser.js +0 -190
  183. package/dist/node_modules/tedious/lib/token/feature-ext-ack-parser.d.ts +0 -5
  184. package/dist/node_modules/tedious/lib/token/feature-ext-ack-parser.js +0 -52
  185. package/dist/node_modules/tedious/lib/token/fedauth-info-parser.d.ts +0 -5
  186. package/dist/node_modules/tedious/lib/token/fedauth-info-parser.js +0 -62
  187. package/dist/node_modules/tedious/lib/token/handler.d.ts +0 -135
  188. package/dist/node_modules/tedious/lib/token/handler.js +0 -444
  189. package/dist/node_modules/tedious/lib/token/helpers.d.ts +0 -28
  190. package/dist/node_modules/tedious/lib/token/helpers.js +0 -205
  191. package/dist/node_modules/tedious/lib/token/infoerror-token-parser.d.ts +0 -5
  192. package/dist/node_modules/tedious/lib/token/infoerror-token-parser.js +0 -80
  193. package/dist/node_modules/tedious/lib/token/loginack-token-parser.d.ts +0 -5
  194. package/dist/node_modules/tedious/lib/token/loginack-token-parser.js +0 -75
  195. package/dist/node_modules/tedious/lib/token/nbcrow-token-parser.d.ts +0 -4
  196. package/dist/node_modules/tedious/lib/token/nbcrow-token-parser.js +0 -104
  197. package/dist/node_modules/tedious/lib/token/order-token-parser.d.ts +0 -5
  198. package/dist/node_modules/tedious/lib/token/order-token-parser.js +0 -34
  199. package/dist/node_modules/tedious/lib/token/returnstatus-token-parser.d.ts +0 -5
  200. package/dist/node_modules/tedious/lib/token/returnstatus-token-parser.js +0 -21
  201. package/dist/node_modules/tedious/lib/token/returnvalue-token-parser.d.ts +0 -4
  202. package/dist/node_modules/tedious/lib/token/returnvalue-token-parser.js +0 -94
  203. package/dist/node_modules/tedious/lib/token/row-token-parser.d.ts +0 -4
  204. package/dist/node_modules/tedious/lib/token/row-token-parser.js +0 -77
  205. package/dist/node_modules/tedious/lib/token/sspi-token-parser.d.ts +0 -5
  206. package/dist/node_modules/tedious/lib/token/sspi-token-parser.js +0 -42
  207. package/dist/node_modules/tedious/lib/token/stream-parser.d.ts +0 -34
  208. package/dist/node_modules/tedious/lib/token/stream-parser.js +0 -341
  209. package/dist/node_modules/tedious/lib/token/token-stream-parser.d.ts +0 -15
  210. package/dist/node_modules/tedious/lib/token/token-stream-parser.js +0 -36
  211. package/dist/node_modules/tedious/lib/token/token.d.ts +0 -312
  212. package/dist/node_modules/tedious/lib/token/token.js +0 -328
  213. package/dist/node_modules/tedious/lib/tracking-buffer/writable-tracking-buffer.d.ts +0 -47
  214. package/dist/node_modules/tedious/lib/tracking-buffer/writable-tracking-buffer.js +0 -249
  215. package/dist/node_modules/tedious/lib/transaction.d.ts +0 -39
  216. package/dist/node_modules/tedious/lib/transaction.js +0 -137
  217. package/dist/node_modules/tedious/lib/transient-error-lookup.d.ts +0 -3
  218. package/dist/node_modules/tedious/lib/transient-error-lookup.js +0 -19
  219. package/dist/node_modules/tedious/lib/utils/with-timeout.d.ts +0 -7
  220. package/dist/node_modules/tedious/lib/utils/with-timeout.js +0 -36
  221. package/dist/node_modules/tedious/lib/value-parser.d.ts +0 -7
  222. package/dist/node_modules/tedious/lib/value-parser.js +0 -813
  223. package/dist/node_modules/tedious/node_modules/@types/node/assert/strict.d.ts +0 -105
  224. package/dist/node_modules/tedious/node_modules/@types/node/assert.d.ts +0 -955
  225. package/dist/node_modules/tedious/node_modules/@types/node/async_hooks.d.ts +0 -623
  226. package/dist/node_modules/tedious/node_modules/@types/node/buffer.buffer.d.ts +0 -466
  227. package/dist/node_modules/tedious/node_modules/@types/node/buffer.d.ts +0 -1810
  228. package/dist/node_modules/tedious/node_modules/@types/node/child_process.d.ts +0 -1428
  229. package/dist/node_modules/tedious/node_modules/@types/node/cluster.d.ts +0 -486
  230. package/dist/node_modules/tedious/node_modules/@types/node/compatibility/iterators.d.ts +0 -21
  231. package/dist/node_modules/tedious/node_modules/@types/node/console.d.ts +0 -151
  232. package/dist/node_modules/tedious/node_modules/@types/node/constants.d.ts +0 -20
  233. package/dist/node_modules/tedious/node_modules/@types/node/crypto.d.ts +0 -4065
  234. package/dist/node_modules/tedious/node_modules/@types/node/dgram.d.ts +0 -564
  235. package/dist/node_modules/tedious/node_modules/@types/node/diagnostics_channel.d.ts +0 -576
  236. package/dist/node_modules/tedious/node_modules/@types/node/dns/promises.d.ts +0 -503
  237. package/dist/node_modules/tedious/node_modules/@types/node/dns.d.ts +0 -922
  238. package/dist/node_modules/tedious/node_modules/@types/node/domain.d.ts +0 -166
  239. package/dist/node_modules/tedious/node_modules/@types/node/events.d.ts +0 -1054
  240. package/dist/node_modules/tedious/node_modules/@types/node/fs/promises.d.ts +0 -1329
  241. package/dist/node_modules/tedious/node_modules/@types/node/fs.d.ts +0 -4676
  242. package/dist/node_modules/tedious/node_modules/@types/node/globals.d.ts +0 -150
  243. package/dist/node_modules/tedious/node_modules/@types/node/globals.typedarray.d.ts +0 -101
  244. package/dist/node_modules/tedious/node_modules/@types/node/http.d.ts +0 -2167
  245. package/dist/node_modules/tedious/node_modules/@types/node/http2.d.ts +0 -2480
  246. package/dist/node_modules/tedious/node_modules/@types/node/https.d.ts +0 -405
  247. package/dist/node_modules/tedious/node_modules/@types/node/index.d.ts +0 -115
  248. package/dist/node_modules/tedious/node_modules/@types/node/inspector/promises.d.ts +0 -41
  249. package/dist/node_modules/tedious/node_modules/@types/node/inspector.d.ts +0 -224
  250. package/dist/node_modules/tedious/node_modules/@types/node/inspector.generated.d.ts +0 -4226
  251. package/dist/node_modules/tedious/node_modules/@types/node/module.d.ts +0 -819
  252. package/dist/node_modules/tedious/node_modules/@types/node/net.d.ts +0 -933
  253. package/dist/node_modules/tedious/node_modules/@types/node/os.d.ts +0 -507
  254. package/dist/node_modules/tedious/node_modules/@types/node/package.json +0 -155
  255. package/dist/node_modules/tedious/node_modules/@types/node/path/posix.d.ts +0 -8
  256. package/dist/node_modules/tedious/node_modules/@types/node/path/win32.d.ts +0 -8
  257. package/dist/node_modules/tedious/node_modules/@types/node/path.d.ts +0 -187
  258. package/dist/node_modules/tedious/node_modules/@types/node/perf_hooks.d.ts +0 -643
  259. package/dist/node_modules/tedious/node_modules/@types/node/process.d.ts +0 -2161
  260. package/dist/node_modules/tedious/node_modules/@types/node/punycode.d.ts +0 -117
  261. package/dist/node_modules/tedious/node_modules/@types/node/querystring.d.ts +0 -152
  262. package/dist/node_modules/tedious/node_modules/@types/node/quic.d.ts +0 -910
  263. package/dist/node_modules/tedious/node_modules/@types/node/readline/promises.d.ts +0 -161
  264. package/dist/node_modules/tedious/node_modules/@types/node/readline.d.ts +0 -541
  265. package/dist/node_modules/tedious/node_modules/@types/node/repl.d.ts +0 -415
  266. package/dist/node_modules/tedious/node_modules/@types/node/sea.d.ts +0 -162
  267. package/dist/node_modules/tedious/node_modules/@types/node/sqlite.d.ts +0 -955
  268. package/dist/node_modules/tedious/node_modules/@types/node/stream/consumers.d.ts +0 -38
  269. package/dist/node_modules/tedious/node_modules/@types/node/stream/promises.d.ts +0 -211
  270. package/dist/node_modules/tedious/node_modules/@types/node/stream/web.d.ts +0 -296
  271. package/dist/node_modules/tedious/node_modules/@types/node/stream.d.ts +0 -1760
  272. package/dist/node_modules/tedious/node_modules/@types/node/string_decoder.d.ts +0 -67
  273. package/dist/node_modules/tedious/node_modules/@types/node/test/reporters.d.ts +0 -96
  274. package/dist/node_modules/tedious/node_modules/@types/node/test.d.ts +0 -2240
  275. package/dist/node_modules/tedious/node_modules/@types/node/timers/promises.d.ts +0 -108
  276. package/dist/node_modules/tedious/node_modules/@types/node/timers.d.ts +0 -159
  277. package/dist/node_modules/tedious/node_modules/@types/node/tls.d.ts +0 -1198
  278. package/dist/node_modules/tedious/node_modules/@types/node/trace_events.d.ts +0 -197
  279. package/dist/node_modules/tedious/node_modules/@types/node/ts5.6/buffer.buffer.d.ts +0 -462
  280. package/dist/node_modules/tedious/node_modules/@types/node/ts5.6/compatibility/float16array.d.ts +0 -71
  281. package/dist/node_modules/tedious/node_modules/@types/node/ts5.6/globals.typedarray.d.ts +0 -36
  282. package/dist/node_modules/tedious/node_modules/@types/node/ts5.6/index.d.ts +0 -117
  283. package/dist/node_modules/tedious/node_modules/@types/node/ts5.7/compatibility/float16array.d.ts +0 -72
  284. package/dist/node_modules/tedious/node_modules/@types/node/ts5.7/index.d.ts +0 -117
  285. package/dist/node_modules/tedious/node_modules/@types/node/tty.d.ts +0 -250
  286. package/dist/node_modules/tedious/node_modules/@types/node/url.d.ts +0 -519
  287. package/dist/node_modules/tedious/node_modules/@types/node/util/types.d.ts +0 -558
  288. package/dist/node_modules/tedious/node_modules/@types/node/util.d.ts +0 -1662
  289. package/dist/node_modules/tedious/node_modules/@types/node/v8.d.ts +0 -983
  290. package/dist/node_modules/tedious/node_modules/@types/node/vm.d.ts +0 -1208
  291. package/dist/node_modules/tedious/node_modules/@types/node/wasi.d.ts +0 -202
  292. package/dist/node_modules/tedious/node_modules/@types/node/web-globals/abortcontroller.d.ts +0 -59
  293. package/dist/node_modules/tedious/node_modules/@types/node/web-globals/blob.d.ts +0 -23
  294. package/dist/node_modules/tedious/node_modules/@types/node/web-globals/console.d.ts +0 -9
  295. package/dist/node_modules/tedious/node_modules/@types/node/web-globals/crypto.d.ts +0 -39
  296. package/dist/node_modules/tedious/node_modules/@types/node/web-globals/domexception.d.ts +0 -68
  297. package/dist/node_modules/tedious/node_modules/@types/node/web-globals/encoding.d.ts +0 -11
  298. package/dist/node_modules/tedious/node_modules/@types/node/web-globals/events.d.ts +0 -106
  299. package/dist/node_modules/tedious/node_modules/@types/node/web-globals/fetch.d.ts +0 -69
  300. package/dist/node_modules/tedious/node_modules/@types/node/web-globals/importmeta.d.ts +0 -13
  301. package/dist/node_modules/tedious/node_modules/@types/node/web-globals/messaging.d.ts +0 -23
  302. package/dist/node_modules/tedious/node_modules/@types/node/web-globals/navigator.d.ts +0 -25
  303. package/dist/node_modules/tedious/node_modules/@types/node/web-globals/performance.d.ts +0 -45
  304. package/dist/node_modules/tedious/node_modules/@types/node/web-globals/storage.d.ts +0 -24
  305. package/dist/node_modules/tedious/node_modules/@types/node/web-globals/streams.d.ts +0 -115
  306. package/dist/node_modules/tedious/node_modules/@types/node/web-globals/timers.d.ts +0 -44
  307. package/dist/node_modules/tedious/node_modules/@types/node/web-globals/url.d.ts +0 -24
  308. package/dist/node_modules/tedious/node_modules/@types/node/worker_threads.d.ts +0 -717
  309. package/dist/node_modules/tedious/node_modules/@types/node/zlib.d.ts +0 -618
  310. package/dist/node_modules/tedious/node_modules/bl/.github/dependabot.yml +0 -16
  311. package/dist/node_modules/tedious/node_modules/bl/.github/workflows/test-and-release.yml +0 -61
  312. package/dist/node_modules/tedious/node_modules/bl/BufferList.d.ts +0 -431
  313. package/dist/node_modules/tedious/node_modules/bl/BufferList.js +0 -421
  314. package/dist/node_modules/tedious/node_modules/bl/bl.js +0 -84
  315. package/dist/node_modules/tedious/node_modules/bl/index.d.ts +0 -88
  316. package/dist/node_modules/tedious/node_modules/bl/package.json +0 -123
  317. package/dist/node_modules/tedious/node_modules/bl/test/convert.js +0 -21
  318. package/dist/node_modules/tedious/node_modules/bl/test/indexOf.js +0 -492
  319. package/dist/node_modules/tedious/node_modules/bl/test/isBufferList.js +0 -32
  320. package/dist/node_modules/tedious/node_modules/bl/test/test.js +0 -1032
  321. package/dist/node_modules/tedious/node_modules/buffer/index.d.ts +0 -194
  322. package/dist/node_modules/tedious/node_modules/buffer/index.js +0 -2106
  323. package/dist/node_modules/tedious/node_modules/buffer/package.json +0 -93
  324. package/dist/node_modules/tedious/node_modules/readable-stream/lib/_stream_duplex.js +0 -4
  325. package/dist/node_modules/tedious/node_modules/readable-stream/lib/_stream_passthrough.js +0 -4
  326. package/dist/node_modules/tedious/node_modules/readable-stream/lib/_stream_readable.js +0 -4
  327. package/dist/node_modules/tedious/node_modules/readable-stream/lib/_stream_transform.js +0 -4
  328. package/dist/node_modules/tedious/node_modules/readable-stream/lib/_stream_writable.js +0 -4
  329. package/dist/node_modules/tedious/node_modules/readable-stream/lib/internal/streams/add-abort-signal.js +0 -52
  330. package/dist/node_modules/tedious/node_modules/readable-stream/lib/internal/streams/buffer_list.js +0 -157
  331. package/dist/node_modules/tedious/node_modules/readable-stream/lib/internal/streams/compose.js +0 -194
  332. package/dist/node_modules/tedious/node_modules/readable-stream/lib/internal/streams/destroy.js +0 -290
  333. package/dist/node_modules/tedious/node_modules/readable-stream/lib/internal/streams/duplex.js +0 -143
  334. package/dist/node_modules/tedious/node_modules/readable-stream/lib/internal/streams/duplexify.js +0 -378
  335. package/dist/node_modules/tedious/node_modules/readable-stream/lib/internal/streams/end-of-stream.js +0 -286
  336. package/dist/node_modules/tedious/node_modules/readable-stream/lib/internal/streams/from.js +0 -98
  337. package/dist/node_modules/tedious/node_modules/readable-stream/lib/internal/streams/lazy_transform.js +0 -51
  338. package/dist/node_modules/tedious/node_modules/readable-stream/lib/internal/streams/legacy.js +0 -89
  339. package/dist/node_modules/tedious/node_modules/readable-stream/lib/internal/streams/operators.js +0 -457
  340. package/dist/node_modules/tedious/node_modules/readable-stream/lib/internal/streams/passthrough.js +0 -39
  341. package/dist/node_modules/tedious/node_modules/readable-stream/lib/internal/streams/pipeline.js +0 -471
  342. package/dist/node_modules/tedious/node_modules/readable-stream/lib/internal/streams/readable.js +0 -1290
  343. package/dist/node_modules/tedious/node_modules/readable-stream/lib/internal/streams/state.js +0 -39
  344. package/dist/node_modules/tedious/node_modules/readable-stream/lib/internal/streams/transform.js +0 -180
  345. package/dist/node_modules/tedious/node_modules/readable-stream/lib/internal/streams/utils.js +0 -327
  346. package/dist/node_modules/tedious/node_modules/readable-stream/lib/internal/streams/writable.js +0 -819
  347. package/dist/node_modules/tedious/node_modules/readable-stream/lib/internal/validators.js +0 -530
  348. package/dist/node_modules/tedious/node_modules/readable-stream/lib/ours/browser.js +0 -35
  349. package/dist/node_modules/tedious/node_modules/readable-stream/lib/ours/errors.js +0 -343
  350. package/dist/node_modules/tedious/node_modules/readable-stream/lib/ours/index.js +0 -65
  351. package/dist/node_modules/tedious/node_modules/readable-stream/lib/ours/primordials.js +0 -124
  352. package/dist/node_modules/tedious/node_modules/readable-stream/lib/ours/util/inspect.js +0 -55
  353. package/dist/node_modules/tedious/node_modules/readable-stream/lib/ours/util.js +0 -148
  354. package/dist/node_modules/tedious/node_modules/readable-stream/lib/stream/promises.js +0 -43
  355. package/dist/node_modules/tedious/node_modules/readable-stream/lib/stream.js +0 -143
  356. package/dist/node_modules/tedious/node_modules/readable-stream/package.json +0 -88
  357. package/dist/node_modules/tedious/node_modules/sprintf-js/dist/.gitattributes +0 -4
  358. package/dist/node_modules/tedious/node_modules/sprintf-js/dist/angular-sprintf.min.js +0 -3
  359. package/dist/node_modules/tedious/node_modules/sprintf-js/dist/sprintf.min.js +0 -3
  360. package/dist/node_modules/tedious/node_modules/sprintf-js/package.json +0 -35
  361. package/dist/node_modules/tedious/node_modules/sprintf-js/src/angular-sprintf.js +0 -24
  362. package/dist/node_modules/tedious/node_modules/sprintf-js/src/sprintf.js +0 -231
  363. package/dist/node_modules/tedious/node_modules/undici-types/agent.d.ts +0 -32
  364. package/dist/node_modules/tedious/node_modules/undici-types/api.d.ts +0 -43
  365. package/dist/node_modules/tedious/node_modules/undici-types/balanced-pool.d.ts +0 -29
  366. package/dist/node_modules/tedious/node_modules/undici-types/cache-interceptor.d.ts +0 -172
  367. package/dist/node_modules/tedious/node_modules/undici-types/cache.d.ts +0 -36
  368. package/dist/node_modules/tedious/node_modules/undici-types/client-stats.d.ts +0 -15
  369. package/dist/node_modules/tedious/node_modules/undici-types/client.d.ts +0 -108
  370. package/dist/node_modules/tedious/node_modules/undici-types/connector.d.ts +0 -34
  371. package/dist/node_modules/tedious/node_modules/undici-types/content-type.d.ts +0 -21
  372. package/dist/node_modules/tedious/node_modules/undici-types/cookies.d.ts +0 -30
  373. package/dist/node_modules/tedious/node_modules/undici-types/diagnostics-channel.d.ts +0 -74
  374. package/dist/node_modules/tedious/node_modules/undici-types/dispatcher.d.ts +0 -276
  375. package/dist/node_modules/tedious/node_modules/undici-types/env-http-proxy-agent.d.ts +0 -22
  376. package/dist/node_modules/tedious/node_modules/undici-types/errors.d.ts +0 -161
  377. package/dist/node_modules/tedious/node_modules/undici-types/eventsource.d.ts +0 -66
  378. package/dist/node_modules/tedious/node_modules/undici-types/fetch.d.ts +0 -211
  379. package/dist/node_modules/tedious/node_modules/undici-types/formdata.d.ts +0 -108
  380. package/dist/node_modules/tedious/node_modules/undici-types/global-dispatcher.d.ts +0 -9
  381. package/dist/node_modules/tedious/node_modules/undici-types/global-origin.d.ts +0 -7
  382. package/dist/node_modules/tedious/node_modules/undici-types/h2c-client.d.ts +0 -73
  383. package/dist/node_modules/tedious/node_modules/undici-types/handlers.d.ts +0 -15
  384. package/dist/node_modules/tedious/node_modules/undici-types/header.d.ts +0 -160
  385. package/dist/node_modules/tedious/node_modules/undici-types/index.d.ts +0 -80
  386. package/dist/node_modules/tedious/node_modules/undici-types/interceptors.d.ts +0 -39
  387. package/dist/node_modules/tedious/node_modules/undici-types/mock-agent.d.ts +0 -68
  388. package/dist/node_modules/tedious/node_modules/undici-types/mock-call-history.d.ts +0 -111
  389. package/dist/node_modules/tedious/node_modules/undici-types/mock-client.d.ts +0 -27
  390. package/dist/node_modules/tedious/node_modules/undici-types/mock-errors.d.ts +0 -12
  391. package/dist/node_modules/tedious/node_modules/undici-types/mock-interceptor.d.ts +0 -94
  392. package/dist/node_modules/tedious/node_modules/undici-types/mock-pool.d.ts +0 -27
  393. package/dist/node_modules/tedious/node_modules/undici-types/package.json +0 -55
  394. package/dist/node_modules/tedious/node_modules/undici-types/patch.d.ts +0 -29
  395. package/dist/node_modules/tedious/node_modules/undici-types/pool-stats.d.ts +0 -19
  396. package/dist/node_modules/tedious/node_modules/undici-types/pool.d.ts +0 -41
  397. package/dist/node_modules/tedious/node_modules/undici-types/proxy-agent.d.ts +0 -29
  398. package/dist/node_modules/tedious/node_modules/undici-types/readable.d.ts +0 -68
  399. package/dist/node_modules/tedious/node_modules/undici-types/retry-agent.d.ts +0 -8
  400. package/dist/node_modules/tedious/node_modules/undici-types/retry-handler.d.ts +0 -125
  401. package/dist/node_modules/tedious/node_modules/undici-types/snapshot-agent.d.ts +0 -109
  402. package/dist/node_modules/tedious/node_modules/undici-types/util.d.ts +0 -18
  403. package/dist/node_modules/tedious/node_modules/undici-types/utility.d.ts +0 -7
  404. package/dist/node_modules/tedious/node_modules/undici-types/webidl.d.ts +0 -341
  405. package/dist/node_modules/tedious/node_modules/undici-types/websocket.d.ts +0 -186
  406. package/dist/node_modules/tedious/package.json +0 -1
  407. package/dist/node_modules/tedious/tsconfig.build-types.json +0 -15
  408. package/dist/node_modules/tedious/tsconfig.json +0 -29
  409. package/dist/node_modules/tedious/types/js-md4.d.ts +0 -7
  410. package/dist/node_modules/tedious/types/native-duplexpair.d.ts +0 -12
@@ -1,1032 +0,0 @@
1
- // @ts-check
2
- 'use strict'
3
-
4
- const tape = require('tape')
5
- const crypto = require('crypto')
6
- const fs = require('fs')
7
- const path = require('path')
8
- const os = require('os')
9
- const BufferListStream = require('../')
10
- const { Buffer } = require('buffer')
11
-
12
- /**
13
- * This typedef allows us to add _bufs to the API without declaring it publicly on types.
14
- * @typedef { BufferListStream & { _bufs?: Buffer[] }} BufferListStreamWithPrivate
15
- */
16
-
17
- /**
18
- * Just for typechecking in js
19
- * @type { NodeJS.Process & { browser?: boolean }}
20
- */
21
-
22
- const process = globalThis.process
23
-
24
- /** @type {BufferEncoding[]} */
25
- const encodings = ['ascii', 'utf8', 'utf-8', 'hex', 'binary', 'base64']
26
-
27
- if (process.browser) {
28
- encodings.push(
29
- 'ucs2',
30
- 'ucs-2',
31
- 'utf16le',
32
- /**
33
- * This alias is not in typescript typings for BufferEncoding. Still have to fix
34
- * @see https://nodejs.org/api/buffer.html#buffers-and-character-encodings
35
- */
36
- // @ts-ignore
37
- 'utf-16le'
38
- )
39
- }
40
-
41
- require('./indexOf')
42
- require('./isBufferList')
43
- require('./convert')
44
-
45
- tape('single bytes from single buffer', function (t) {
46
- const bl = new BufferListStream()
47
-
48
- bl.append(Buffer.from('abcd'))
49
-
50
- t.equal(bl.length, 4)
51
- t.equal(bl.get(-1), undefined)
52
- t.equal(bl.get(0), 97)
53
- t.equal(bl.get(1), 98)
54
- t.equal(bl.get(2), 99)
55
- t.equal(bl.get(3), 100)
56
- t.equal(bl.get(4), undefined)
57
-
58
- t.end()
59
- })
60
-
61
- tape('single bytes from multiple buffers', function (t) {
62
- const bl = new BufferListStream()
63
-
64
- bl.append(Buffer.from('abcd'))
65
- bl.append(Buffer.from('efg'))
66
- bl.append(Buffer.from('hi'))
67
- bl.append(Buffer.from('j'))
68
-
69
- t.equal(bl.length, 10)
70
-
71
- t.equal(bl.get(0), 97)
72
- t.equal(bl.get(1), 98)
73
- t.equal(bl.get(2), 99)
74
- t.equal(bl.get(3), 100)
75
- t.equal(bl.get(4), 101)
76
- t.equal(bl.get(5), 102)
77
- t.equal(bl.get(6), 103)
78
- t.equal(bl.get(7), 104)
79
- t.equal(bl.get(8), 105)
80
- t.equal(bl.get(9), 106)
81
-
82
- t.end()
83
- })
84
-
85
- tape('multi bytes from single buffer', function (t) {
86
- const bl = new BufferListStream()
87
-
88
- bl.append(Buffer.from('abcd'))
89
-
90
- t.equal(bl.length, 4)
91
-
92
- t.equal(bl.slice(0, 4).toString('ascii'), 'abcd')
93
- t.equal(bl.slice(0, 3).toString('ascii'), 'abc')
94
- t.equal(bl.slice(1, 4).toString('ascii'), 'bcd')
95
- t.equal(bl.slice(-4, -1).toString('ascii'), 'abc')
96
-
97
- t.end()
98
- })
99
-
100
- tape('multi bytes from single buffer (negative indexes)', function (t) {
101
- const bl = new BufferListStream()
102
-
103
- bl.append(Buffer.from('buffer'))
104
-
105
- t.equal(bl.length, 6)
106
-
107
- t.equal(bl.slice(-6, -1).toString('ascii'), 'buffe')
108
- t.equal(bl.slice(-6, -2).toString('ascii'), 'buff')
109
- t.equal(bl.slice(-5, -2).toString('ascii'), 'uff')
110
-
111
- t.end()
112
- })
113
-
114
- tape('multiple bytes from multiple buffers', function (t) {
115
- const bl = new BufferListStream()
116
-
117
- bl.append(Buffer.from('abcd'))
118
- bl.append(Buffer.from('efg'))
119
- bl.append(Buffer.from('hi'))
120
- bl.append(Buffer.from('j'))
121
-
122
- t.equal(bl.length, 10)
123
-
124
- t.equal(bl.slice(0, 10).toString('ascii'), 'abcdefghij')
125
- t.equal(bl.slice(3, 10).toString('ascii'), 'defghij')
126
- t.equal(bl.slice(3, 6).toString('ascii'), 'def')
127
- t.equal(bl.slice(3, 8).toString('ascii'), 'defgh')
128
- t.equal(bl.slice(5, 10).toString('ascii'), 'fghij')
129
- t.equal(bl.slice(-7, -4).toString('ascii'), 'def')
130
-
131
- t.end()
132
- })
133
-
134
- tape('multiple bytes from multiple buffer lists', function (t) {
135
- const bl = new BufferListStream()
136
-
137
- bl.append(new BufferListStream([Buffer.from('abcd'), Buffer.from('efg')]))
138
- bl.append(new BufferListStream([Buffer.from('hi'), Buffer.from('j')]))
139
-
140
- t.equal(bl.length, 10)
141
-
142
- t.equal(bl.slice(0, 10).toString('ascii'), 'abcdefghij')
143
-
144
- t.equal(bl.slice(3, 10).toString('ascii'), 'defghij')
145
- t.equal(bl.slice(3, 6).toString('ascii'), 'def')
146
- t.equal(bl.slice(3, 8).toString('ascii'), 'defgh')
147
- t.equal(bl.slice(5, 10).toString('ascii'), 'fghij')
148
-
149
- t.end()
150
- })
151
-
152
- // same data as previous test, just using nested constructors
153
- tape('multiple bytes from crazy nested buffer lists', function (t) {
154
- const bl = new BufferListStream()
155
-
156
- bl.append(
157
- new BufferListStream([
158
- new BufferListStream([
159
- new BufferListStream(Buffer.from('abc')),
160
- Buffer.from('d'),
161
- new BufferListStream(Buffer.from('efg'))
162
- ]),
163
- new BufferListStream([Buffer.from('hi')]),
164
- new BufferListStream(Buffer.from('j'))
165
- ])
166
- )
167
-
168
- t.equal(bl.length, 10)
169
-
170
- t.equal(bl.slice(0, 10).toString('ascii'), 'abcdefghij')
171
-
172
- t.equal(bl.slice(3, 10).toString('ascii'), 'defghij')
173
- t.equal(bl.slice(3, 6).toString('ascii'), 'def')
174
- t.equal(bl.slice(3, 8).toString('ascii'), 'defgh')
175
- t.equal(bl.slice(5, 10).toString('ascii'), 'fghij')
176
-
177
- t.end()
178
- })
179
-
180
- tape('append accepts arrays of Buffers', function (t) {
181
- const bl = new BufferListStream()
182
-
183
- bl.append(Buffer.from('abc'))
184
- bl.append([Buffer.from('def')])
185
- bl.append([Buffer.from('ghi'), Buffer.from('jkl')])
186
- bl.append([Buffer.from('mnop'), Buffer.from('qrstu'), Buffer.from('vwxyz')])
187
- t.equal(bl.length, 26)
188
- t.equal(bl.slice().toString('ascii'), 'abcdefghijklmnopqrstuvwxyz')
189
-
190
- t.end()
191
- })
192
-
193
- tape('append accepts arrays of Uint8Arrays', function (t) {
194
- const bl = new BufferListStream()
195
-
196
- bl.append(new Uint8Array([97, 98, 99]))
197
- bl.append([Uint8Array.from([100, 101, 102])])
198
- bl.append([new Uint8Array([103, 104, 105]), new Uint8Array([106, 107, 108])])
199
- bl.append([new Uint8Array([109, 110, 111, 112]), new Uint8Array([113, 114, 115, 116, 117]), new Uint8Array([118, 119, 120, 121, 122])])
200
- t.equal(bl.length, 26)
201
- t.equal(bl.slice().toString('ascii'), 'abcdefghijklmnopqrstuvwxyz')
202
-
203
- t.end()
204
- })
205
-
206
- tape('append accepts arrays of BufferLists', function (t) {
207
- const bl = new BufferListStream()
208
-
209
- bl.append(Buffer.from('abc'))
210
- bl.append([new BufferListStream('def')])
211
- bl.append(
212
- new BufferListStream([Buffer.from('ghi'), new BufferListStream('jkl')])
213
- )
214
- bl.append([
215
- Buffer.from('mnop'),
216
- new BufferListStream([Buffer.from('qrstu'), Buffer.from('vwxyz')])
217
- ])
218
- t.equal(bl.length, 26)
219
- t.equal(bl.slice().toString('ascii'), 'abcdefghijklmnopqrstuvwxyz')
220
-
221
- t.end()
222
- })
223
-
224
- tape('append chainable', function (t) {
225
- const bl = new BufferListStream()
226
-
227
- t.ok(bl.append(Buffer.from('abcd')) === bl)
228
- t.ok(bl.append([Buffer.from('abcd')]) === bl)
229
- t.ok(bl.append(new BufferListStream(Buffer.from('abcd'))) === bl)
230
- t.ok(bl.append([new BufferListStream(Buffer.from('abcd'))]) === bl)
231
-
232
- t.end()
233
- })
234
-
235
- tape('append chainable (test results)', function (t) {
236
- const bl = new BufferListStream('abc')
237
- .append([new BufferListStream('def')])
238
- .append(
239
- new BufferListStream([Buffer.from('ghi'), new BufferListStream('jkl')])
240
- )
241
- .append([
242
- Buffer.from('mnop'),
243
- new BufferListStream([Buffer.from('qrstu'), Buffer.from('vwxyz')])
244
- ])
245
-
246
- t.equal(bl.length, 26)
247
- t.equal(bl.slice().toString('ascii'), 'abcdefghijklmnopqrstuvwxyz')
248
-
249
- t.end()
250
- })
251
-
252
- tape('prepend accepts arrays of Buffers', function (t) {
253
- const bl = new BufferListStream()
254
-
255
- bl.prepend(Buffer.from('abc'))
256
- bl.prepend([Buffer.from('def')])
257
- bl.prepend([Buffer.from('ghi'), Buffer.from('jkl')])
258
- bl.prepend([Buffer.from('mnop'), Buffer.from('qrstu'), Buffer.from('vwxyz')])
259
- t.equal(bl.length, 26)
260
- t.equal(bl.slice().toString('ascii'), 'mnopqrstuvwxyzghijkldefabc')
261
-
262
- t.end()
263
- })
264
-
265
- tape('prepend accepts arrays of Uint8Arrays', function (t) {
266
- const bl = new BufferListStream()
267
-
268
- bl.prepend(new Uint8Array([97, 98, 99]))
269
- bl.prepend([Uint8Array.from([100, 101, 102])])
270
- bl.prepend([new Uint8Array([103, 104, 105]), new Uint8Array([106, 107, 108])])
271
- bl.prepend([new Uint8Array([109, 110, 111, 112]), new Uint8Array([113, 114, 115, 116, 117]), new Uint8Array([118, 119, 120, 121, 122])])
272
- t.equal(bl.length, 26)
273
- t.equal(bl.slice().toString('ascii'), 'mnopqrstuvwxyzghijkldefabc')
274
-
275
- t.end()
276
- })
277
-
278
- tape('prepend accepts arrays of BufferLists', function (t) {
279
- const bl = new BufferListStream()
280
-
281
- bl.prepend(Buffer.from('abc'))
282
- bl.prepend([new BufferListStream('def')])
283
- bl.prepend(
284
- new BufferListStream([Buffer.from('ghi'), new BufferListStream('jkl')])
285
- )
286
- bl.prepend([
287
- Buffer.from('mnop'),
288
- new BufferListStream([Buffer.from('qrstu'), Buffer.from('vwxyz')])
289
- ])
290
- t.equal(bl.length, 26)
291
- t.equal(bl.slice().toString('ascii'), 'mnopqrstuvwxyzghijkldefabc')
292
-
293
- t.end()
294
- })
295
-
296
- tape('prepend chainable', function (t) {
297
- const bl = new BufferListStream()
298
-
299
- t.ok(bl.prepend(Buffer.from('abcd')) === bl)
300
- t.ok(bl.prepend([Buffer.from('abcd')]) === bl)
301
- t.ok(bl.prepend(new BufferListStream(Buffer.from('abcd'))) === bl)
302
- t.ok(bl.prepend([new BufferListStream(Buffer.from('abcd'))]) === bl)
303
-
304
- t.end()
305
- })
306
-
307
- tape('prepend chainable (test results)', function (t) {
308
- const bl = new BufferListStream('abc')
309
- .prepend([new BufferListStream('def')])
310
- .prepend(
311
- new BufferListStream([Buffer.from('ghi'), new BufferListStream('jkl')])
312
- )
313
- .prepend([
314
- Buffer.from('mnop'),
315
- new BufferListStream([Buffer.from('qrstu'), Buffer.from('vwxyz')])
316
- ])
317
-
318
- t.equal(bl.length, 26)
319
- t.equal(bl.slice().toString('ascii'), 'mnopqrstuvwxyzghijkldefabc')
320
-
321
- t.end()
322
- })
323
-
324
- tape('consuming from multiple buffers', function (t) {
325
- const bl = new BufferListStream()
326
-
327
- bl.append(Buffer.from('abcd'))
328
- bl.append(Buffer.from('efg'))
329
- bl.append(Buffer.from('hi'))
330
- bl.append(Buffer.from('j'))
331
-
332
- t.equal(bl.length, 10)
333
-
334
- t.equal(bl.slice(0, 10).toString('ascii'), 'abcdefghij')
335
-
336
- bl.consume(3)
337
- t.equal(bl.length, 7)
338
- t.equal(bl.slice(0, 7).toString('ascii'), 'defghij')
339
-
340
- bl.consume(2)
341
- t.equal(bl.length, 5)
342
- t.equal(bl.slice(0, 5).toString('ascii'), 'fghij')
343
-
344
- bl.consume(1)
345
- t.equal(bl.length, 4)
346
- t.equal(bl.slice(0, 4).toString('ascii'), 'ghij')
347
-
348
- bl.consume(1)
349
- t.equal(bl.length, 3)
350
- t.equal(bl.slice(0, 3).toString('ascii'), 'hij')
351
-
352
- bl.consume(2)
353
- t.equal(bl.length, 1)
354
- t.equal(bl.slice(0, 1).toString('ascii'), 'j')
355
-
356
- t.end()
357
- })
358
-
359
- tape('complete consumption', function (t) {
360
- /** @type {BufferListStreamWithPrivate} */
361
- const bl = new BufferListStream()
362
-
363
- bl.append(Buffer.from('a'))
364
- bl.append(Buffer.from('b'))
365
-
366
- bl.consume(2)
367
-
368
- t.equal(bl.length, 0)
369
- t.equal(bl._bufs.length, 0)
370
-
371
- t.end()
372
- })
373
-
374
- tape('test readUInt8 / readInt8', function (t) {
375
- const buf1 = Buffer.alloc(1)
376
- const buf2 = Buffer.alloc(3)
377
- const buf3 = Buffer.alloc(3)
378
- const bl = new BufferListStream()
379
-
380
- buf1[0] = 0x1
381
- buf2[1] = 0x3
382
- buf2[2] = 0x4
383
- buf3[0] = 0x23
384
- buf3[1] = 0x42
385
-
386
- bl.append(buf1)
387
- bl.append(buf2)
388
- bl.append(buf3)
389
-
390
- t.equal(bl.readUInt8(), 0x1)
391
- t.equal(bl.readUInt8(2), 0x3)
392
- t.equal(bl.readInt8(2), 0x3)
393
- t.equal(bl.readUInt8(3), 0x4)
394
- t.equal(bl.readInt8(3), 0x4)
395
- t.equal(bl.readUInt8(4), 0x23)
396
- t.equal(bl.readInt8(4), 0x23)
397
- t.equal(bl.readUInt8(5), 0x42)
398
- t.equal(bl.readInt8(5), 0x42)
399
-
400
- t.end()
401
- })
402
-
403
- tape('test readUInt16LE / readUInt16BE / readInt16LE / readInt16BE', function (t) {
404
- const buf1 = Buffer.alloc(1)
405
- const buf2 = Buffer.alloc(3)
406
- const buf3 = Buffer.alloc(3)
407
- const bl = new BufferListStream()
408
-
409
- buf1[0] = 0x1
410
- buf2[1] = 0x3
411
- buf2[2] = 0x4
412
- buf3[0] = 0x23
413
- buf3[1] = 0x42
414
-
415
- bl.append(buf1)
416
- bl.append(buf2)
417
- bl.append(buf3)
418
-
419
- t.equal(bl.readUInt16BE(), 0x0100)
420
- t.equal(bl.readUInt16LE(), 0x0001)
421
- t.equal(bl.readUInt16BE(2), 0x0304)
422
- t.equal(bl.readUInt16LE(2), 0x0403)
423
- t.equal(bl.readInt16BE(2), 0x0304)
424
- t.equal(bl.readInt16LE(2), 0x0403)
425
- t.equal(bl.readUInt16BE(3), 0x0423)
426
- t.equal(bl.readUInt16LE(3), 0x2304)
427
- t.equal(bl.readInt16BE(3), 0x0423)
428
- t.equal(bl.readInt16LE(3), 0x2304)
429
- t.equal(bl.readUInt16BE(4), 0x2342)
430
- t.equal(bl.readUInt16LE(4), 0x4223)
431
- t.equal(bl.readInt16BE(4), 0x2342)
432
- t.equal(bl.readInt16LE(4), 0x4223)
433
-
434
- t.end()
435
- })
436
-
437
- tape('test readUInt32LE / readUInt32BE / readInt32LE / readInt32BE', function (t) {
438
- const buf1 = Buffer.alloc(1)
439
- const buf2 = Buffer.alloc(3)
440
- const buf3 = Buffer.alloc(3)
441
- const bl = new BufferListStream()
442
-
443
- buf1[0] = 0x1
444
- buf2[1] = 0x3
445
- buf2[2] = 0x4
446
- buf3[0] = 0x23
447
- buf3[1] = 0x42
448
-
449
- bl.append(buf1)
450
- bl.append(buf2)
451
- bl.append(buf3)
452
-
453
- t.equal(bl.readUInt32BE(), 0x01000304)
454
- t.equal(bl.readUInt32LE(), 0x04030001)
455
- t.equal(bl.readUInt32BE(2), 0x03042342)
456
- t.equal(bl.readUInt32LE(2), 0x42230403)
457
- t.equal(bl.readInt32BE(2), 0x03042342)
458
- t.equal(bl.readInt32LE(2), 0x42230403)
459
-
460
- t.end()
461
- })
462
-
463
- tape('test readBigUInt64LE / readBigUInt64BE / readBigInt64LE / readBigInt64BE', function (t) {
464
- const buf1 = Buffer.alloc(1)
465
- const buf2 = Buffer.alloc(3)
466
- const buf3 = Buffer.alloc(2)
467
- const buf4 = Buffer.alloc(5)
468
- const bl = new BufferListStream()
469
-
470
- buf1[0] = 0x05
471
- buf2[0] = 0x07
472
-
473
- buf2[1] = 0x03
474
- buf2[2] = 0x04
475
- buf3[0] = 0x23
476
- buf3[1] = 0x42
477
- buf4[0] = 0x00
478
- buf4[1] = 0x01
479
- buf4[2] = 0x02
480
- buf4[3] = 0x03
481
-
482
- buf4[4] = 0x04
483
-
484
- bl.append(buf1)
485
- bl.append(buf2)
486
- bl.append(buf3)
487
- bl.append(buf4)
488
-
489
- t.equal(bl.readBigUInt64BE(2), 0x0304234200010203n)
490
- t.equal(bl.readBigUInt64LE(2), 0x0302010042230403n)
491
- t.equal(bl.readBigInt64BE(2), 0x0304234200010203n)
492
- t.equal(bl.readBigInt64LE(2), 0x0302010042230403n)
493
-
494
- t.end()
495
- })
496
-
497
- tape('test readUIntLE / readUIntBE / readIntLE / readIntBE', function (t) {
498
- const buf1 = Buffer.alloc(1)
499
- const buf2 = Buffer.alloc(3)
500
- const buf3 = Buffer.alloc(3)
501
- const bl = new BufferListStream()
502
-
503
- buf2[0] = 0x2
504
- buf2[1] = 0x3
505
- buf2[2] = 0x4
506
- buf3[0] = 0x23
507
- buf3[1] = 0x42
508
- buf3[2] = 0x61
509
-
510
- bl.append(buf1)
511
- bl.append(buf2)
512
- bl.append(buf3)
513
-
514
- t.equal(bl.readUIntBE(1, 1), 0x02)
515
- t.equal(bl.readUIntBE(1, 2), 0x0203)
516
- t.equal(bl.readUIntBE(1, 3), 0x020304)
517
- t.equal(bl.readUIntBE(1, 4), 0x02030423)
518
- t.equal(bl.readUIntBE(1, 5), 0x0203042342)
519
- t.equal(bl.readUIntBE(1, 6), 0x020304234261)
520
- t.equal(bl.readUIntLE(1, 1), 0x02)
521
- t.equal(bl.readUIntLE(1, 2), 0x0302)
522
- t.equal(bl.readUIntLE(1, 3), 0x040302)
523
- t.equal(bl.readUIntLE(1, 4), 0x23040302)
524
- t.equal(bl.readUIntLE(1, 5), 0x4223040302)
525
- t.equal(bl.readUIntLE(1, 6), 0x614223040302)
526
- t.equal(bl.readIntBE(1, 1), 0x02)
527
- t.equal(bl.readIntBE(1, 2), 0x0203)
528
- t.equal(bl.readIntBE(1, 3), 0x020304)
529
- t.equal(bl.readIntBE(1, 4), 0x02030423)
530
- t.equal(bl.readIntBE(1, 5), 0x0203042342)
531
- t.equal(bl.readIntBE(1, 6), 0x020304234261)
532
- t.equal(bl.readIntLE(1, 1), 0x02)
533
- t.equal(bl.readIntLE(1, 2), 0x0302)
534
- t.equal(bl.readIntLE(1, 3), 0x040302)
535
- t.equal(bl.readIntLE(1, 4), 0x23040302)
536
- t.equal(bl.readIntLE(1, 5), 0x4223040302)
537
- t.equal(bl.readIntLE(1, 6), 0x614223040302)
538
-
539
- t.end()
540
- })
541
-
542
- tape('test readFloatLE / readFloatBE', function (t) {
543
- const buf1 = Buffer.alloc(1)
544
- const buf2 = Buffer.alloc(3)
545
- const buf3 = Buffer.alloc(3)
546
- const bl = new BufferListStream()
547
-
548
- buf1[0] = 0x01
549
- buf2[1] = 0x00
550
- buf2[2] = 0x00
551
- buf3[0] = 0x80
552
- buf3[1] = 0x3f
553
-
554
- bl.append(buf1)
555
- bl.append(buf2)
556
- bl.append(buf3)
557
-
558
- const canonical = Buffer.concat([buf1, buf2, buf3])
559
- t.equal(bl.readFloatLE(), canonical.readFloatLE())
560
- t.equal(bl.readFloatBE(), canonical.readFloatBE())
561
- t.equal(bl.readFloatLE(2), canonical.readFloatLE(2))
562
- t.equal(bl.readFloatBE(2), canonical.readFloatBE(2))
563
-
564
- t.end()
565
- })
566
-
567
- tape('test readDoubleLE / readDoubleBE', function (t) {
568
- const buf1 = Buffer.alloc(1)
569
- const buf2 = Buffer.alloc(3)
570
- const buf3 = Buffer.alloc(10)
571
- const bl = new BufferListStream()
572
-
573
- buf1[0] = 0x01
574
- buf2[1] = 0x55
575
- buf2[2] = 0x55
576
- buf3[0] = 0x55
577
- buf3[1] = 0x55
578
- buf3[2] = 0x55
579
- buf3[3] = 0x55
580
- buf3[4] = 0xd5
581
- buf3[5] = 0x3f
582
-
583
- bl.append(buf1)
584
- bl.append(buf2)
585
- bl.append(buf3)
586
-
587
- const canonical = Buffer.concat([buf1, buf2, buf3])
588
- t.equal(bl.readDoubleBE(), canonical.readDoubleBE())
589
- t.equal(bl.readDoubleLE(), canonical.readDoubleLE())
590
- t.equal(bl.readDoubleBE(2), canonical.readDoubleBE(2))
591
- t.equal(bl.readDoubleLE(2), canonical.readDoubleLE(2))
592
-
593
- t.end()
594
- })
595
-
596
- tape('test toString', function (t) {
597
- const bl = new BufferListStream()
598
-
599
- bl.append(Buffer.from('abcd'))
600
- bl.append(Buffer.from('efg'))
601
- bl.append(Buffer.from('hi'))
602
- bl.append(Buffer.from('j'))
603
-
604
- t.equal(bl.toString('ascii', 0, 10), 'abcdefghij')
605
- t.equal(bl.toString('ascii', 3, 10), 'defghij')
606
- t.equal(bl.toString('ascii', 3, 6), 'def')
607
- t.equal(bl.toString('ascii', 3, 8), 'defgh')
608
- t.equal(bl.toString('ascii', 5, 10), 'fghij')
609
-
610
- t.end()
611
- })
612
-
613
- tape('test toString encoding', function (t) {
614
- const bl = new BufferListStream()
615
- const b = Buffer.from('abcdefghij\xff\x00')
616
-
617
- bl.append(Buffer.from('abcd'))
618
- bl.append(Buffer.from('efg'))
619
- bl.append(Buffer.from('hi'))
620
- bl.append(Buffer.from('j'))
621
- bl.append(Buffer.from('\xff\x00'))
622
-
623
- encodings.forEach(function (enc) {
624
- t.equal(bl.toString(enc), b.toString(enc), enc)
625
- })
626
-
627
- t.end()
628
- })
629
-
630
- tape('getBuffers', function (t) {
631
- const bl = new BufferListStream([Buffer.from('First'), Buffer.from('Second'), Buffer.from('Third')])
632
-
633
- t.deepEquals(
634
- bl.getBuffers(),
635
- // @ts-ignore
636
- bl._bufs
637
- )
638
-
639
- t.end()
640
- })
641
-
642
- tape('uninitialized memory', function (t) {
643
- const secret = crypto.randomBytes(256)
644
- for (let i = 0; i < 1e6; i++) {
645
- const clone = Buffer.from(secret)
646
- const bl = new BufferListStream()
647
- bl.append(Buffer.from('a'))
648
- bl.consume(-1024)
649
- const buf = bl.slice(1)
650
- if (buf.indexOf(clone) !== -1) {
651
- t.fail(`Match (at ${i})`)
652
- break
653
- }
654
- }
655
- t.end()
656
- })
657
-
658
- !process.browser && tape('test stream', function (t) {
659
- const random = crypto.randomBytes(65534)
660
-
661
- const bl = new BufferListStream((err, buf) => {
662
- t.ok(Buffer.isBuffer(buf))
663
- t.ok(err === null)
664
- t.ok(random.equals(bl.slice()))
665
- t.ok(random.equals(buf.slice()))
666
-
667
- bl.pipe(fs.createWriteStream(path.join(os.tmpdir(), 'bl_test_rnd_out.dat')))
668
- .on('close', function () {
669
- const rndhash = crypto.createHash('md5').update(random).digest('hex')
670
- const md5sum = crypto.createHash('md5')
671
- const s = fs.createReadStream(path.join(os.tmpdir(), 'bl_test_rnd_out.dat'))
672
-
673
- s.on('data', md5sum.update.bind(md5sum))
674
- s.on('end', function () {
675
- t.equal(rndhash, md5sum.digest('hex'), 'woohoo! correct hash!')
676
- t.end()
677
- })
678
- })
679
- })
680
-
681
- fs.writeFileSync(path.join(os.tmpdir(), 'bl_test_rnd.dat'), random)
682
- fs.createReadStream(path.join(os.tmpdir(), 'bl_test_rnd.dat')).pipe(bl)
683
- })
684
-
685
- tape('instantiation with Buffer', function (t) {
686
- const buf = crypto.randomBytes(1024)
687
- const buf2 = crypto.randomBytes(1024)
688
- let b = BufferListStream(buf)
689
-
690
- t.equal(buf.toString('hex'), b.slice().toString('hex'), 'same buffer')
691
- b = BufferListStream([buf, buf2])
692
- t.equal(b.slice().toString('hex'), Buffer.concat([buf, buf2]).toString('hex'), 'same buffer')
693
-
694
- t.end()
695
- })
696
-
697
- tape('test String appendage', function (t) {
698
- const bl = new BufferListStream()
699
- const b = Buffer.from('abcdefghij\xff\x00')
700
-
701
- bl.append('abcd')
702
- bl.append('efg')
703
- bl.append('hi')
704
- bl.append('j')
705
- bl.append('\xff\x00')
706
-
707
- encodings.forEach(function (enc) {
708
- t.equal(bl.toString(enc), b.toString(enc))
709
- })
710
-
711
- t.end()
712
- })
713
-
714
- tape('test Number appendage', function (t) {
715
- const bl = new BufferListStream()
716
- const b = Buffer.from('1234567890')
717
-
718
- bl.append(1234)
719
- bl.append(567)
720
- bl.append(89)
721
- bl.append(0)
722
-
723
- encodings.forEach(function (enc) {
724
- t.equal(bl.toString(enc), b.toString(enc))
725
- })
726
-
727
- t.end()
728
- })
729
-
730
- tape('write nothing, should get empty buffer', function (t) {
731
- t.plan(3)
732
- BufferListStream(function (err, data) {
733
- t.notOk(err, 'no error')
734
- t.ok(Buffer.isBuffer(data), 'got a buffer')
735
- t.equal(0, data.length, 'got a zero-length buffer')
736
- t.end()
737
- }).end()
738
- })
739
-
740
- tape('unicode string', function (t) {
741
- t.plan(2)
742
-
743
- const inp1 = '\u2600'
744
- const inp2 = '\u2603'
745
- const exp = inp1 + ' and ' + inp2
746
- const bl = BufferListStream()
747
-
748
- bl.write(inp1)
749
- bl.write(' and ')
750
- bl.write(inp2)
751
- t.equal(exp, bl.toString())
752
- t.equal(Buffer.from(exp).toString('hex'), bl.toString('hex'))
753
- })
754
-
755
- tape('should emit finish', function (t) {
756
- const source = BufferListStream()
757
- const dest = BufferListStream()
758
-
759
- source.write('hello')
760
- source.pipe(dest)
761
-
762
- dest.on('finish', function () {
763
- t.equal(dest.toString('utf8'), 'hello')
764
- t.end()
765
- })
766
- })
767
-
768
- tape('basic copy', function (t) {
769
- const buf = crypto.randomBytes(1024)
770
- const buf2 = Buffer.alloc(1024)
771
- const b = BufferListStream(buf)
772
-
773
- b.copy(buf2)
774
- t.equal(b.slice().toString('hex'), buf2.toString('hex'), 'same buffer')
775
-
776
- t.end()
777
- })
778
-
779
- tape('copy after many appends', function (t) {
780
- const buf = crypto.randomBytes(512)
781
- const buf2 = Buffer.alloc(1024)
782
- const b = BufferListStream(buf)
783
-
784
- b.append(buf)
785
- b.copy(buf2)
786
- t.equal(b.slice().toString('hex'), buf2.toString('hex'), 'same buffer')
787
-
788
- t.end()
789
- })
790
-
791
- tape('copy at a precise position', function (t) {
792
- const buf = crypto.randomBytes(1004)
793
- const buf2 = Buffer.alloc(1024)
794
- const b = BufferListStream(buf)
795
-
796
- b.copy(buf2, 20)
797
- t.equal(b.slice().toString('hex'), buf2.slice(20).toString('hex'), 'same buffer')
798
-
799
- t.end()
800
- })
801
-
802
- tape('copy starting from a precise location', function (t) {
803
- const buf = crypto.randomBytes(10)
804
- const buf2 = Buffer.alloc(5)
805
- const b = BufferListStream(buf)
806
-
807
- b.copy(buf2, 0, 5)
808
- t.equal(b.slice(5).toString('hex'), buf2.toString('hex'), 'same buffer')
809
-
810
- t.end()
811
- })
812
-
813
- tape('copy in an interval', function (t) {
814
- const rnd = crypto.randomBytes(10)
815
- const b = BufferListStream(rnd) // put the random bytes there
816
- const actual = Buffer.alloc(3)
817
- const expected = Buffer.alloc(3)
818
-
819
- rnd.copy(expected, 0, 5, 8)
820
- b.copy(actual, 0, 5, 8)
821
-
822
- t.equal(actual.toString('hex'), expected.toString('hex'), 'same buffer')
823
-
824
- t.end()
825
- })
826
-
827
- tape('copy an interval between two buffers', function (t) {
828
- const buf = crypto.randomBytes(10)
829
- const buf2 = Buffer.alloc(10)
830
- const b = BufferListStream(buf)
831
-
832
- b.append(buf)
833
- b.copy(buf2, 0, 5, 15)
834
-
835
- t.equal(b.slice(5, 15).toString('hex'), buf2.toString('hex'), 'same buffer')
836
-
837
- t.end()
838
- })
839
-
840
- tape('shallow slice across buffer boundaries', function (t) {
841
- const bl = new BufferListStream(['First', 'Second', 'Third'])
842
-
843
- t.equal(bl.shallowSlice(3, 13).toString(), 'stSecondTh')
844
-
845
- t.end()
846
- })
847
-
848
- tape('shallow slice within single buffer', function (t) {
849
- t.plan(2)
850
-
851
- const bl = new BufferListStream(['First', 'Second', 'Third'])
852
-
853
- t.equal(bl.shallowSlice(5, 10).toString(), 'Secon')
854
- t.equal(bl.shallowSlice(7, 10).toString(), 'con')
855
-
856
- t.end()
857
- })
858
-
859
- tape('shallow slice single buffer', function (t) {
860
- t.plan(3)
861
-
862
- const bl = new BufferListStream(['First', 'Second', 'Third'])
863
-
864
- t.equal(bl.shallowSlice(0, 5).toString(), 'First')
865
- t.equal(bl.shallowSlice(5, 11).toString(), 'Second')
866
- t.equal(bl.shallowSlice(11, 16).toString(), 'Third')
867
- })
868
-
869
- tape('shallow slice with negative or omitted indices', function (t) {
870
- t.plan(4)
871
-
872
- const bl = new BufferListStream(['First', 'Second', 'Third'])
873
-
874
- t.equal(bl.shallowSlice().toString(), 'FirstSecondThird')
875
- t.equal(bl.shallowSlice(5).toString(), 'SecondThird')
876
- t.equal(bl.shallowSlice(5, -3).toString(), 'SecondTh')
877
- t.equal(bl.shallowSlice(-8).toString(), 'ondThird')
878
- })
879
-
880
- tape('shallow slice does not make a copy', function (t) {
881
- t.plan(1)
882
-
883
- const buffers = [Buffer.from('First'), Buffer.from('Second'), Buffer.from('Third')]
884
- const bl = new BufferListStream(buffers).shallowSlice(5, -3)
885
-
886
- buffers[1].fill('h')
887
- buffers[2].fill('h')
888
-
889
- t.equal(bl.toString(), 'hhhhhhhh')
890
- })
891
-
892
- tape('shallow slice with 0 length', function (t) {
893
- t.plan(1)
894
-
895
- const buffers = [Buffer.from('First'), Buffer.from('Second'), Buffer.from('Third')]
896
- const bl = (new BufferListStream(buffers)).shallowSlice(0, 0)
897
-
898
- t.equal(bl.length, 0)
899
- })
900
-
901
- tape('shallow slice with 0 length from middle', function (t) {
902
- t.plan(1)
903
-
904
- const buffers = [Buffer.from('First'), Buffer.from('Second'), Buffer.from('Third')]
905
- const bl = (new BufferListStream(buffers)).shallowSlice(10, 10)
906
-
907
- t.equal(bl.length, 0)
908
- })
909
-
910
- tape('duplicate', function (t) {
911
- t.plan(2)
912
-
913
- const bl = new BufferListStream('abcdefghij\xff\x00')
914
- const dup = bl.duplicate()
915
-
916
- t.equal(bl.prototype, dup.prototype)
917
- t.equal(bl.toString('hex'), dup.toString('hex'))
918
- })
919
-
920
- tape('destroy no pipe', function (t) {
921
- t.plan(2)
922
-
923
- /** @type {BufferListStreamWithPrivate} */
924
- const bl = new BufferListStream('alsdkfja;lsdkfja;lsdk')
925
-
926
- bl.destroy()
927
-
928
- t.equal(bl._bufs.length, 0)
929
- t.equal(bl.length, 0)
930
- })
931
-
932
- tape('destroy with error', function (t) {
933
- t.plan(3)
934
-
935
- /** @type {BufferListStreamWithPrivate} */
936
- const bl = new BufferListStream('alsdkfja;lsdkfja;lsdk')
937
- const err = new Error('kaboom')
938
-
939
- bl.destroy(err)
940
- bl.on('error', function (_err) {
941
- t.equal(_err, err)
942
- })
943
-
944
- t.equal(bl._bufs.length, 0)
945
- t.equal(bl.length, 0)
946
- })
947
-
948
- !process.browser && tape('destroy with pipe before read end', function (t) {
949
- t.plan(2)
950
-
951
- /** @type {BufferListStreamWithPrivate} */
952
- const bl = new BufferListStream()
953
- fs.createReadStream(path.join(__dirname, '/test.js'))
954
- .pipe(bl)
955
-
956
- bl.destroy()
957
-
958
- t.equal(bl._bufs.length, 0)
959
- t.equal(bl.length, 0)
960
- })
961
-
962
- !process.browser && tape('destroy with pipe before read end with race', function (t) {
963
- t.plan(2)
964
-
965
- /** @type {BufferListStreamWithPrivate} */
966
- const bl = new BufferListStream()
967
-
968
- fs.createReadStream(path.join(__dirname, '/test.js'))
969
- .pipe(bl)
970
-
971
- setTimeout(function () {
972
- bl.destroy()
973
- setTimeout(function () {
974
- t.equal(bl._bufs.length, 0)
975
- t.equal(bl.length, 0)
976
- }, 500)
977
- }, 500)
978
- })
979
-
980
- !process.browser && tape('destroy with pipe after read end', function (t) {
981
- t.plan(2)
982
-
983
- /** @type {BufferListStreamWithPrivate} */
984
- const bl = new BufferListStream()
985
- fs.createReadStream(path.join(__dirname, '/test.js'))
986
- .on('end', onEnd)
987
- .pipe(bl)
988
-
989
- function onEnd () {
990
- bl.destroy()
991
-
992
- t.equal(bl._bufs.length, 0)
993
- t.equal(bl.length, 0)
994
- }
995
- })
996
-
997
- !process.browser && tape('destroy with pipe while writing to a destination', function (t) {
998
- t.plan(4)
999
-
1000
- /** @type {BufferListStreamWithPrivate} */
1001
- const bl = new BufferListStream()
1002
- const ds = new BufferListStream()
1003
-
1004
- fs.createReadStream(path.join(__dirname, '/test.js'))
1005
- .on('end', onEnd)
1006
- .pipe(bl)
1007
-
1008
- function onEnd () {
1009
- bl.pipe(ds)
1010
-
1011
- setTimeout(function () {
1012
- bl.destroy()
1013
-
1014
- t.equals(bl._bufs.length, 0)
1015
- t.equals(bl.length, 0)
1016
-
1017
- ds.destroy()
1018
-
1019
- t.equals(bl._bufs.length, 0)
1020
- t.equals(bl.length, 0)
1021
- }, 100)
1022
- }
1023
- })
1024
-
1025
- !process.browser && tape('handle error', function (t) {
1026
- t.plan(2)
1027
-
1028
- fs.createReadStream('/does/not/exist').pipe(BufferListStream(function (err, data) {
1029
- t.ok(err instanceof Error, 'has error')
1030
- t.notOk(data, 'no data')
1031
- }))
1032
- })