bl 5.0.0 → 6.0.0

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.
@@ -0,0 +1,16 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: 'github-actions'
4
+ directory: '/'
5
+ schedule:
6
+ interval: 'daily'
7
+ commit-message:
8
+ prefix: 'chore'
9
+ include: 'scope'
10
+ - package-ecosystem: 'npm'
11
+ directory: '/'
12
+ schedule:
13
+ interval: 'daily'
14
+ commit-message:
15
+ prefix: 'chore'
16
+ include: 'scope'
@@ -0,0 +1,61 @@
1
+ name: Test & Maybe Release
2
+ on: [push, pull_request]
3
+ jobs:
4
+ test:
5
+ strategy:
6
+ fail-fast: false
7
+ matrix:
8
+ node: [14.x, 16.x, 18.x, lts/*, current]
9
+ os: [macos-latest, ubuntu-latest, windows-latest]
10
+ runs-on: ${{ matrix.os }}
11
+ steps:
12
+ - name: Checkout Repository
13
+ uses: actions/checkout@v3
14
+ - name: Use Node.js ${{ matrix.node }}
15
+ uses: actions/setup-node@v3.5.1
16
+ with:
17
+ node-version: ${{ matrix.node }}
18
+ - name: Install Dependencies
19
+ run: |
20
+ npm install --no-progress
21
+ - name: Run tests
22
+ run: |
23
+ npm config set script-shell bash
24
+ npm run test:ci
25
+ release:
26
+ name: Release
27
+ needs: test
28
+ runs-on: ubuntu-latest
29
+ if: github.event_name == 'push' && github.ref == 'refs/heads/master'
30
+ steps:
31
+ - name: Checkout
32
+ uses: actions/checkout@v3
33
+ with:
34
+ fetch-depth: 0
35
+ - name: Setup Node.js
36
+ uses: actions/setup-node@v3.5.1
37
+ with:
38
+ node-version: 14
39
+ - name: Install dependencies
40
+ run: |
41
+ npm install --no-progress --no-package-lock --no-save
42
+ - name: Build
43
+ run: |
44
+ npm run build
45
+ - name: Install plugins
46
+ run: |
47
+ npm install \
48
+ @semantic-release/commit-analyzer \
49
+ conventional-changelog-conventionalcommits \
50
+ @semantic-release/release-notes-generator \
51
+ @semantic-release/npm \
52
+ @semantic-release/github \
53
+ @semantic-release/git \
54
+ @semantic-release/changelog \
55
+ --no-progress --no-package-lock --no-save
56
+ - name: Release
57
+ env:
58
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
59
+ NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
60
+ run: npx semantic-release
61
+
@@ -0,0 +1,418 @@
1
+ export type BufferListAcceptedTypes =
2
+ | Buffer
3
+ | BufferList
4
+ | Uint8Array
5
+ | BufferListAcceptedTypes[]
6
+ | string
7
+ | number;
8
+
9
+ export interface BufferListConstructor {
10
+ new (initData?: BufferListAcceptedTypes): BufferList;
11
+ (initData?: BufferListAcceptedTypes): BufferList;
12
+
13
+ /**
14
+ * Determines if the passed object is a BufferList. It will return true
15
+ * if the passed object is an instance of BufferList or BufferListStream
16
+ * and false otherwise.
17
+ *
18
+ * N.B. this won't return true for BufferList or BufferListStream instances
19
+ * created by versions of this library before this static method was added.
20
+ *
21
+ * @param other
22
+ */
23
+
24
+ isBufferList(other: unknown): boolean;
25
+ }
26
+
27
+ interface BufferList {
28
+ prototype: Object
29
+
30
+ /**
31
+ * Get the length of the list in bytes. This is the sum of the lengths
32
+ * of all of the buffers contained in the list, minus any initial offset
33
+ * for a semi-consumed buffer at the beginning. Should accurately
34
+ * represent the total number of bytes that can be read from the list.
35
+ */
36
+
37
+ length: number;
38
+
39
+ /**
40
+ * Adds an additional buffer or BufferList to the internal list.
41
+ * this is returned so it can be chained.
42
+ *
43
+ * @param buffer
44
+ */
45
+
46
+ append(buffer: BufferListAcceptedTypes): this;
47
+
48
+ /**
49
+ * Will return the byte at the specified index.
50
+ * @param index
51
+ */
52
+
53
+ get(index: number): number;
54
+
55
+ /**
56
+ * Returns a new Buffer object containing the bytes within the
57
+ * range specified. Both start and end are optional and will
58
+ * default to the beginning and end of the list respectively.
59
+ *
60
+ * If the requested range spans a single internal buffer then a
61
+ * slice of that buffer will be returned which shares the original
62
+ * memory range of that Buffer. If the range spans multiple buffers
63
+ * then copy operations will likely occur to give you a uniform Buffer.
64
+ *
65
+ * @param start
66
+ * @param end
67
+ */
68
+
69
+ slice(start?: number, end?: number): Buffer;
70
+
71
+ /**
72
+ * Returns a new BufferList object containing the bytes within the
73
+ * range specified. Both start and end are optional and will default
74
+ * to the beginning and end of the list respectively.
75
+ *
76
+ * No copies will be performed. All buffers in the result share
77
+ * memory with the original list.
78
+ *
79
+ * @param start
80
+ * @param end
81
+ */
82
+
83
+ shallowSlice(start?: number, end?: number): this;
84
+
85
+ /**
86
+ * Copies the content of the list in the `dest` buffer, starting from
87
+ * `destStart` and containing the bytes within the range specified
88
+ * with `srcStart` to `srcEnd`.
89
+ *
90
+ * `destStart`, `start` and `end` are optional and will default to the
91
+ * beginning of the dest buffer, and the beginning and end of the
92
+ * list respectively.
93
+ *
94
+ * @param dest
95
+ * @param destStart
96
+ * @param srcStart
97
+ * @param srcEnd
98
+ */
99
+
100
+ copy(
101
+ dest: Buffer,
102
+ destStart?: number,
103
+ srcStart?: number,
104
+ srcEnd?: number
105
+ ): Buffer;
106
+
107
+ /**
108
+ * Performs a shallow-copy of the list. The internal Buffers remains the
109
+ * same, so if you change the underlying Buffers, the change will be
110
+ * reflected in both the original and the duplicate.
111
+ *
112
+ * This method is needed if you want to call consume() or pipe() and
113
+ * still keep the original list.
114
+ *
115
+ * @example
116
+ *
117
+ * ```js
118
+ * var bl = new BufferListStream();
119
+ * bl.append('hello');
120
+ * bl.append(' world');
121
+ * bl.append('\n');
122
+ * bl.duplicate().pipe(process.stdout, { end: false });
123
+ *
124
+ * console.log(bl.toString())
125
+ * ```
126
+ */
127
+
128
+ duplicate(): this;
129
+
130
+ /**
131
+ * Will shift bytes off the start of the list. The number of bytes
132
+ * consumed don't need to line up with the sizes of the internal
133
+ * Buffers—initial offsets will be calculated accordingly in order
134
+ * to give you a consistent view of the data.
135
+ *
136
+ * @param bytes
137
+ */
138
+
139
+ consume(bytes?: number): void;
140
+
141
+ /**
142
+ * Will return a string representation of the buffer. The optional
143
+ * `start` and `end` arguments are passed on to `slice()`, while
144
+ * the encoding is passed on to `toString()` of the resulting Buffer.
145
+ *
146
+ * See the [`Buffer#toString()`](http://nodejs.org/docs/latest/api/buffer.html#buffer_buf_tostring_encoding_start_end)
147
+ * documentation for more information.
148
+ *
149
+ * @param encoding
150
+ * @param start
151
+ * @param end
152
+ */
153
+
154
+ toString(encoding?: string, start?: number, end?: number): string;
155
+
156
+ /**
157
+ * Will return the byte at the specified index. indexOf() method
158
+ * returns the first index at which a given element can be found
159
+ * in the BufferList, or -1 if it is not present.
160
+ *
161
+ * @param value
162
+ * @param byteOffset
163
+ * @param encoding
164
+ */
165
+
166
+ indexOf(
167
+ value: string | number | Uint8Array | BufferList | Buffer,
168
+ byteOffset?: number,
169
+ encoding?: string
170
+ ): number;
171
+
172
+ /**
173
+ * All of the standard byte-reading methods of the Buffer interface are implemented and will operate across internal Buffer boundaries transparently.
174
+ * See the [Buffer](http://nodejs.org/docs/latest/api/buffer.html) documentation for how these work.
175
+ *
176
+ * @param offset
177
+ */
178
+
179
+ readDoubleBE: Buffer['readDoubleBE'];
180
+
181
+ /**
182
+ * All of the standard byte-reading methods of the Buffer interface are implemented and will operate across internal Buffer boundaries transparently.
183
+ * See the [Buffer](http://nodejs.org/docs/latest/api/buffer.html) documentation for how these work.
184
+ *
185
+ * @param offset
186
+ */
187
+
188
+ readDoubleLE: Buffer['readDoubleLE'];
189
+
190
+ /**
191
+ * All of the standard byte-reading methods of the Buffer interface are implemented and will operate across internal Buffer boundaries transparently.
192
+ * See the [Buffer](http://nodejs.org/docs/latest/api/buffer.html) documentation for how these work.
193
+ *
194
+ * @param offset
195
+ */
196
+
197
+ readFloatBE: Buffer['readFloatBE'];
198
+
199
+ /**
200
+ * All of the standard byte-reading methods of the Buffer interface are implemented and will operate across internal Buffer boundaries transparently.
201
+ * See the [Buffer](http://nodejs.org/docs/latest/api/buffer.html) documentation for how these work.
202
+ *
203
+ * @param offset
204
+ */
205
+
206
+ readFloatLE: Buffer['readFloatLE'];
207
+
208
+ /**
209
+ * All of the standard byte-reading methods of the Buffer interface are implemented and will operate across internal Buffer boundaries transparently.
210
+ * See the [Buffer](http://nodejs.org/docs/latest/api/buffer.html) documentation for how these work.
211
+ *
212
+ * @param offset
213
+ */
214
+
215
+ readBigInt64BE: Buffer['readBigInt64BE'];
216
+
217
+ /**
218
+ * All of the standard byte-reading methods of the Buffer interface are implemented and will operate across internal Buffer boundaries transparently.
219
+ * See the [Buffer](http://nodejs.org/docs/latest/api/buffer.html) documentation for how these work.
220
+ *
221
+ * @param offset
222
+ */
223
+
224
+ readBigInt64LE: Buffer['readBigInt64LE'];
225
+
226
+ /**
227
+ * All of the standard byte-reading methods of the Buffer interface are implemented and will operate across internal Buffer boundaries transparently.
228
+ * See the [Buffer](http://nodejs.org/docs/latest/api/buffer.html) documentation for how these work.
229
+ *
230
+ * @param offset
231
+ */
232
+
233
+ readBigUInt64BE: Buffer['readBigUInt64BE'];
234
+
235
+ /**
236
+ * All of the standard byte-reading methods of the Buffer interface are implemented and will operate across internal Buffer boundaries transparently.
237
+ * See the [Buffer](http://nodejs.org/docs/latest/api/buffer.html) documentation for how these work.
238
+ *
239
+ * @param offset
240
+ */
241
+
242
+ readBigUInt64LE: Buffer['readBigUInt64LE'];
243
+
244
+ /**
245
+ * All of the standard byte-reading methods of the Buffer interface are implemented and will operate across internal Buffer boundaries transparently.
246
+ * See the [Buffer](http://nodejs.org/docs/latest/api/buffer.html) documentation for how these work.
247
+ *
248
+ * @param offset
249
+ */
250
+
251
+ readInt32BE: Buffer['readInt32BE'];
252
+
253
+ /**
254
+ * All of the standard byte-reading methods of the Buffer interface are implemented and will operate across internal Buffer boundaries transparently.
255
+ * See the [Buffer](http://nodejs.org/docs/latest/api/buffer.html) documentation for how these work.
256
+ *
257
+ * @param offset
258
+ */
259
+
260
+ readInt32LE: Buffer['readInt32LE'];
261
+
262
+ /**
263
+ * All of the standard byte-reading methods of the Buffer interface are implemented and will operate across internal Buffer boundaries transparently.
264
+ * See the [Buffer](http://nodejs.org/docs/latest/api/buffer.html) documentation for how these work.
265
+ *
266
+ * @param offset
267
+ */
268
+
269
+ readUInt32BE: Buffer['readUInt32BE'];
270
+
271
+ /**
272
+ * All of the standard byte-reading methods of the Buffer interface are implemented and will operate across internal Buffer boundaries transparently.
273
+ * See the [Buffer](http://nodejs.org/docs/latest/api/buffer.html) documentation for how these work.
274
+ *
275
+ * @param offset
276
+ */
277
+
278
+ readUInt32LE: Buffer['readUInt32LE'];
279
+
280
+ /**
281
+ * All of the standard byte-reading methods of the Buffer interface are implemented and will operate across internal Buffer boundaries transparently.
282
+ * See the [Buffer](http://nodejs.org/docs/latest/api/buffer.html) documentation for how these work.
283
+ *
284
+ * @param offset
285
+ */
286
+
287
+ readInt16BE: Buffer['readInt16BE'];
288
+
289
+ /**
290
+ * All of the standard byte-reading methods of the Buffer interface are
291
+ * implemented and will operate across internal Buffer boundaries transparently.
292
+ *
293
+ * See the [Buffer](http://nodejs.org/docs/latest/api/buffer.html)
294
+ * documentation for how these work.
295
+ *
296
+ * @param offset
297
+ */
298
+
299
+ readInt16LE: Buffer['readInt16LE'];
300
+
301
+ /**
302
+ * All of the standard byte-reading methods of the Buffer interface are
303
+ * implemented and will operate across internal Buffer boundaries transparently.
304
+ *
305
+ * See the [Buffer](http://nodejs.org/docs/latest/api/buffer.html)
306
+ * documentation for how these work.
307
+ *
308
+ * @param offset
309
+ */
310
+
311
+ readUInt16BE: Buffer['readUInt16BE'];
312
+
313
+ /**
314
+ * All of the standard byte-reading methods of the Buffer interface are
315
+ * implemented and will operate across internal Buffer boundaries transparently.
316
+ *
317
+ * See the [Buffer](http://nodejs.org/docs/latest/api/buffer.html)
318
+ * documentation for how these work.
319
+ *
320
+ * @param offset
321
+ */
322
+
323
+ readUInt16LE: Buffer['readUInt16LE'];
324
+
325
+ /**
326
+ * All of the standard byte-reading methods of the Buffer interface are
327
+ * implemented and will operate across internal Buffer boundaries transparently.
328
+ *
329
+ * See the [Buffer](http://nodejs.org/docs/latest/api/buffer.html)
330
+ * documentation for how these work.
331
+ *
332
+ * @param offset
333
+ */
334
+
335
+ readInt8: Buffer['readInt8'];
336
+
337
+ /**
338
+ * All of the standard byte-reading methods of the Buffer interface are
339
+ * implemented and will operate across internal Buffer boundaries transparently.
340
+ *
341
+ * See the [Buffer](http://nodejs.org/docs/latest/api/buffer.html)
342
+ * documentation for how these work.
343
+ *
344
+ * @param offset
345
+ */
346
+
347
+ readUInt8: Buffer['readUInt8'];
348
+
349
+ /**
350
+ * All of the standard byte-reading methods of the Buffer interface are
351
+ * implemented and will operate across internal Buffer boundaries transparently.
352
+ *
353
+ * See the [Buffer](http://nodejs.org/docs/latest/api/buffer.html)
354
+ * documentation for how these work.
355
+ *
356
+ * @param offset
357
+ */
358
+
359
+ readIntBE: Buffer['readIntBE'];
360
+
361
+ /**
362
+ * All of the standard byte-reading methods of the Buffer interface are
363
+ * implemented and will operate across internal Buffer boundaries transparently.
364
+ *
365
+ * See the [Buffer](http://nodejs.org/docs/latest/api/buffer.html)
366
+ * documentation for how these work.
367
+ *
368
+ * @param offset
369
+ */
370
+
371
+ readIntLE: Buffer['readIntLE'];
372
+
373
+ /**
374
+ * All of the standard byte-reading methods of the Buffer interface are
375
+ * implemented and will operate across internal Buffer boundaries transparently.
376
+ *
377
+ * See the [Buffer](http://nodejs.org/docs/latest/api/buffer.html)
378
+ * documentation for how these work.
379
+ *
380
+ * @param offset
381
+ */
382
+
383
+ readUIntBE: Buffer['readUIntBE'];
384
+
385
+ /**
386
+ * All of the standard byte-reading methods of the Buffer interface are
387
+ * implemented and will operate across internal Buffer boundaries transparently.
388
+ *
389
+ * See the [Buffer](http://nodejs.org/docs/latest/api/buffer.html)
390
+ * documentation for how these work.
391
+ *
392
+ * @param offset
393
+ */
394
+
395
+ readUIntLE: Buffer['readUIntLE'];
396
+ }
397
+
398
+ /**
399
+ * No arguments are required for the constructor, but you can initialise
400
+ * the list by passing in a single Buffer object or an array of Buffer
401
+ * objects.
402
+ *
403
+ * `new` is not strictly required, if you don't instantiate a new object,
404
+ * it will be done automatically for you so you can create a new instance
405
+ * simply with:
406
+ *
407
+ * ```js
408
+ * const { BufferList } = require('bl')
409
+ * const bl = BufferList()
410
+ *
411
+ * // equivalent to:
412
+ *
413
+ * const { BufferList } = require('bl')
414
+ * const bl = new BufferList()
415
+ * ```
416
+ */
417
+
418
+ declare const BufferList: BufferListConstructor;
package/BufferList.js CHANGED
@@ -350,6 +350,10 @@ BufferList.prototype._match = function (offset, search) {
350
350
  readDoubleLE: 8,
351
351
  readFloatBE: 4,
352
352
  readFloatLE: 4,
353
+ readBigInt64BE: 8,
354
+ readBigInt64LE: 8,
355
+ readBigUInt64BE: 8,
356
+ readBigUInt64LE: 8,
353
357
  readInt32BE: 4,
354
358
  readInt32LE: 4,
355
359
  readUInt32BE: 4,
package/CHANGELOG.md ADDED
@@ -0,0 +1,37 @@
1
+ ## [6.0.0](https://github.com/rvagg/bl/compare/v5.1.0...v6.0.0) (2022-10-19)
2
+
3
+
4
+ ### ⚠ BREAKING CHANGES
5
+
6
+ * **deps:** bump readable-stream from 3.6.0 to 4.2.0
7
+ * added bigint (Int64) support
8
+
9
+ ### Features
10
+
11
+ * added bigint (Int64) support ([131ad32](https://github.com/rvagg/bl/commit/131ad3217b91090323513a8ea3ef179e8427cf47))
12
+
13
+
14
+ ### Trivial Changes
15
+
16
+ * add TypeScript definitions for BigInt ([78c5ff4](https://github.com/rvagg/bl/commit/78c5ff489235a4e4233086c364133123c71acef4))
17
+ * **deps-dev:** bump typescript from 4.7.4 to 4.8.4 ([dba13e1](https://github.com/rvagg/bl/commit/dba13e1cadc5857dde6a9425e975faf2abbb270f))
18
+ * **deps:** bump readable-stream from 3.6.0 to 4.2.0 ([fa03eda](https://github.com/rvagg/bl/commit/fa03eda54b4412c0fdfc9053bd0b0bebaf80bfd9))
19
+ * **docs:** BigInt in API docs ([c68af50](https://github.com/rvagg/bl/commit/c68af500a04b2c3a14132ae6946412d2e39402d0))
20
+
21
+ ## [5.1.0](https://github.com/rvagg/bl/compare/v5.0.0...v5.1.0) (2022-10-18)
22
+
23
+
24
+ ### Features
25
+
26
+ * added integrated TypeScript typings ([#108](https://github.com/rvagg/bl/issues/108)) ([433ff89](https://github.com/rvagg/bl/commit/433ff8942f47fab8a5c9d13b2c00989ccf8d0710))
27
+
28
+
29
+ ### Bug Fixes
30
+
31
+ * windows support in tests ([387dfaf](https://github.com/rvagg/bl/commit/387dfaf9b2bca7849f12785436ceb01e42adac2c))
32
+
33
+
34
+ ### Trivial Changes
35
+
36
+ * GH Actions, Dependabot, auto-release, remove Travis ([997f058](https://github.com/rvagg/bl/commit/997f058357de8f2a7f66998e80a72b491835573f))
37
+ * **no-release:** bump standard from 16.0.4 to 17.0.0 ([#112](https://github.com/rvagg/bl/issues/112)) ([078bfe3](https://github.com/rvagg/bl/commit/078bfe33390d125297b1c946e5989c4aa9228961))
package/README.md CHANGED
@@ -98,7 +98,7 @@ bl.pipe(fs.createWriteStream('gibberish.txt'))
98
98
  * <a href="#duplicate"><code>bl.<b>duplicate()</b></code></a>
99
99
  * <a href="#consume"><code>bl.<b>consume(bytes)</b></code></a>
100
100
  * <a href="#toString"><code>bl.<b>toString([encoding, [ start, [ end ]]])</b></code></a>
101
- * <a href="#readXX"><code>bl.<b>readDoubleBE()</b></code>, <code>bl.<b>readDoubleLE()</b></code>, <code>bl.<b>readFloatBE()</b></code>, <code>bl.<b>readFloatLE()</b></code>, <code>bl.<b>readInt32BE()</b></code>, <code>bl.<b>readInt32LE()</b></code>, <code>bl.<b>readUInt32BE()</b></code>, <code>bl.<b>readUInt32LE()</b></code>, <code>bl.<b>readInt16BE()</b></code>, <code>bl.<b>readInt16LE()</b></code>, <code>bl.<b>readUInt16BE()</b></code>, <code>bl.<b>readUInt16LE()</b></code>, <code>bl.<b>readInt8()</b></code>, <code>bl.<b>readUInt8()</b></code></a>
101
+ * <a href="#readXX"><code>bl.<b>readDoubleBE()</b></code>, <code>bl.<b>readDoubleLE()</b></code>, <code>bl.<b>readFloatBE()</b></code>, <code>bl.<b>readFloatLE()</b></code>, <code>bl.<b>readBigInt64BE()</b></code>, <code>bl.<b>readBigInt64LE()</b></code>, <code>bl.<b>readBigUInt64BE()</b></code>, <code>bl.<b>readBigUInt64LE()</b></code>, <code>bl.<b>readInt32BE()</b></code>, <code>bl.<b>readInt32LE()</b></code>, <code>bl.<b>readUInt32BE()</b></code>, <code>bl.<b>readUInt32LE()</b></code>, <code>bl.<b>readInt16BE()</b></code>, <code>bl.<b>readInt16LE()</b></code>, <code>bl.<b>readUInt16BE()</b></code>, <code>bl.<b>readUInt16LE()</b></code>, <code>bl.<b>readInt8()</b></code>, <code>bl.<b>readUInt8()</b></code></a>
102
102
  * <a href="#ctorStream"><code><b>new BufferListStream([ callback ])</b></code></a>
103
103
 
104
104
  --------------------------------------------------------
@@ -194,7 +194,7 @@ console.log(bl.toString())
194
194
 
195
195
  --------------------------------------------------------
196
196
  <a name="readXX"></a>
197
- ### bl.readDoubleBE(), bl.readDoubleLE(), bl.readFloatBE(), bl.readFloatLE(), bl.readInt32BE(), bl.readInt32LE(), bl.readUInt32BE(), bl.readUInt32LE(), bl.readInt16BE(), bl.readInt16LE(), bl.readUInt16BE(), bl.readUInt16LE(), bl.readInt8(), bl.readUInt8()
197
+ ### bl.readDoubleBE(), bl.readDoubleLE(), bl.readFloatBE(), bl.readFloatLE(), bl.readBigIntBE(), bl.readBigIntLE(), bl.readBigUIntBE(), bl.readBigUIntLE(), bl.readInt32BE(), bl.readInt32LE(), bl.readUInt32BE(), bl.readUInt32LE(), bl.readInt16BE(), bl.readInt16LE(), bl.readUInt16BE(), bl.readUInt16LE(), bl.readInt8(), bl.readUInt8()
198
198
 
199
199
  All of the standard byte-reading methods of the `Buffer` interface are implemented and will operate across internal Buffer boundaries transparently.
200
200
 
package/index.d.ts ADDED
@@ -0,0 +1,88 @@
1
+ import { Duplex } from "readable-stream";
2
+ import {
3
+ BufferList as BL,
4
+ BufferListConstructor,
5
+ BufferListAcceptedTypes,
6
+ } from "./BufferList";
7
+
8
+ type BufferListStreamInit =
9
+ | ((err: Error, buffer: Buffer) => void)
10
+ | BufferListAcceptedTypes;
11
+
12
+ interface BufferListStreamConstructor {
13
+ new (initData?: BufferListStreamInit): BufferListStream;
14
+ (callback?: BufferListStreamInit): BufferListStream;
15
+
16
+ /**
17
+ * Determines if the passed object is a BufferList. It will return true
18
+ * if the passed object is an instance of BufferList or BufferListStream
19
+ * and false otherwise.
20
+ *
21
+ * N.B. this won't return true for BufferList or BufferListStream instances
22
+ * created by versions of this library before this static method was added.
23
+ *
24
+ * @param other
25
+ */
26
+
27
+ isBufferList(other: unknown): boolean;
28
+
29
+ /**
30
+ * Rexporting BufferList and BufferListStream to fix
31
+ * issue with require/commonjs import and "export = " below.
32
+ */
33
+
34
+ BufferList: BufferListConstructor;
35
+ BufferListStream: BufferListStreamConstructor;
36
+ }
37
+
38
+ interface BufferListStream extends Duplex, BL {
39
+ prototype: BufferListStream & BL;
40
+ }
41
+
42
+ /**
43
+ * BufferListStream is a Node Duplex Stream, so it can be read from
44
+ * and written to like a standard Node stream. You can also pipe()
45
+ * to and from a BufferListStream instance.
46
+ *
47
+ * The constructor takes an optional callback, if supplied, the
48
+ * callback will be called with an error argument followed by a
49
+ * reference to the bl instance, when bl.end() is called
50
+ * (i.e. from a piped stream).
51
+ *
52
+ * This is a convenient method of collecting the entire contents of
53
+ * a stream, particularly when the stream is chunky, such as a network
54
+ * stream.
55
+ *
56
+ * Normally, no arguments are required for the constructor, but you can
57
+ * initialise the list by passing in a single Buffer object or an array
58
+ * of Buffer object.
59
+ *
60
+ * `new` is not strictly required, if you don't instantiate a new object,
61
+ * it will be done automatically for you so you can create a new instance
62
+ * simply with:
63
+ *
64
+ * ```js
65
+ * const { BufferListStream } = require('bl');
66
+ * const bl = BufferListStream();
67
+ *
68
+ * // equivalent to:
69
+ *
70
+ * const { BufferListStream } = require('bl');
71
+ * const bl = new BufferListStream();
72
+ * ```
73
+ *
74
+ * N.B. For backwards compatibility reasons, BufferListStream is the default
75
+ * export when you `require('bl')`:
76
+ *
77
+ * ```js
78
+ * const { BufferListStream } = require('bl')
79
+ *
80
+ * // equivalent to:
81
+ *
82
+ * const BufferListStream = require('bl')
83
+ * ```
84
+ */
85
+
86
+ declare const BufferListStream: BufferListStreamConstructor;
87
+
88
+ export = BufferListStream;