bl 6.1.6 → 7.0.1

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.
package/BufferList.d.ts DELETED
@@ -1,431 +0,0 @@
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
- * Adds an additional buffer or BufferList at the beginning of the internal list.
50
- * this is returned so it can be chained.
51
- *
52
- * @param buffer
53
- */
54
- prepend(buffer: BufferListAcceptedTypes): this;
55
-
56
- /**
57
- * Will return the byte at the specified index.
58
- * @param index
59
- */
60
-
61
- get(index: number): number;
62
-
63
- /**
64
- * Returns a new Buffer object containing the bytes within the
65
- * range specified. Both start and end are optional and will
66
- * default to the beginning and end of the list respectively.
67
- *
68
- * If the requested range spans a single internal buffer then a
69
- * slice of that buffer will be returned which shares the original
70
- * memory range of that Buffer. If the range spans multiple buffers
71
- * then copy operations will likely occur to give you a uniform Buffer.
72
- *
73
- * @param start
74
- * @param end
75
- */
76
-
77
- slice(start?: number, end?: number): Buffer;
78
-
79
- /**
80
- * Returns a new BufferList object containing the bytes within the
81
- * range specified. Both start and end are optional and will default
82
- * to the beginning and end of the list respectively.
83
- *
84
- * No copies will be performed. All buffers in the result share
85
- * memory with the original list.
86
- *
87
- * @param start
88
- * @param end
89
- */
90
-
91
- shallowSlice(start?: number, end?: number): this;
92
-
93
- /**
94
- * Copies the content of the list in the `dest` buffer, starting from
95
- * `destStart` and containing the bytes within the range specified
96
- * with `srcStart` to `srcEnd`.
97
- *
98
- * `destStart`, `start` and `end` are optional and will default to the
99
- * beginning of the dest buffer, and the beginning and end of the
100
- * list respectively.
101
- *
102
- * @param dest
103
- * @param destStart
104
- * @param srcStart
105
- * @param srcEnd
106
- */
107
-
108
- copy(
109
- dest: Buffer,
110
- destStart?: number,
111
- srcStart?: number,
112
- srcEnd?: number
113
- ): Buffer;
114
-
115
- /**
116
- * Performs a shallow-copy of the list. The internal Buffers remains the
117
- * same, so if you change the underlying Buffers, the change will be
118
- * reflected in both the original and the duplicate.
119
- *
120
- * This method is needed if you want to call consume() or pipe() and
121
- * still keep the original list.
122
- *
123
- * @example
124
- *
125
- * ```js
126
- * var bl = new BufferListStream();
127
- * bl.append('hello');
128
- * bl.append(' world');
129
- * bl.append('\n');
130
- * bl.duplicate().pipe(process.stdout, { end: false });
131
- *
132
- * console.log(bl.toString())
133
- * ```
134
- */
135
-
136
- duplicate(): this;
137
-
138
- /**
139
- * Will shift bytes off the start of the list. The number of bytes
140
- * consumed don't need to line up with the sizes of the internal
141
- * Buffers—initial offsets will be calculated accordingly in order
142
- * to give you a consistent view of the data.
143
- *
144
- * @param bytes
145
- */
146
-
147
- consume(bytes?: number): void;
148
-
149
- /**
150
- * Will return a string representation of the buffer. The optional
151
- * `start` and `end` arguments are passed on to `slice()`, while
152
- * the encoding is passed on to `toString()` of the resulting Buffer.
153
- *
154
- * See the [`Buffer#toString()`](http://nodejs.org/docs/latest/api/buffer.html#buffer_buf_tostring_encoding_start_end)
155
- * documentation for more information.
156
- *
157
- * @param encoding
158
- * @param start
159
- * @param end
160
- */
161
-
162
- toString(encoding?: string, start?: number, end?: number): string;
163
-
164
- /**
165
- * Will return the byte at the specified index. indexOf() method
166
- * returns the first index at which a given element can be found
167
- * in the BufferList, or -1 if it is not present.
168
- *
169
- * @param value
170
- * @param byteOffset
171
- * @param encoding
172
- */
173
-
174
- indexOf(
175
- value: string | number | Uint8Array | BufferList | Buffer,
176
- byteOffset?: number,
177
- encoding?: string
178
- ): number;
179
-
180
- /**
181
- * Will return the internal list of buffers.
182
- */
183
- getBuffers(): Buffer[];
184
-
185
- /**
186
- * All of the standard byte-reading methods of the Buffer interface are implemented and will operate across internal Buffer boundaries transparently.
187
- * See the [Buffer](http://nodejs.org/docs/latest/api/buffer.html) documentation for how these work.
188
- *
189
- * @param offset
190
- */
191
-
192
- readDoubleBE: Buffer['readDoubleBE'];
193
-
194
- /**
195
- * All of the standard byte-reading methods of the Buffer interface are implemented and will operate across internal Buffer boundaries transparently.
196
- * See the [Buffer](http://nodejs.org/docs/latest/api/buffer.html) documentation for how these work.
197
- *
198
- * @param offset
199
- */
200
-
201
- readDoubleLE: Buffer['readDoubleLE'];
202
-
203
- /**
204
- * All of the standard byte-reading methods of the Buffer interface are implemented and will operate across internal Buffer boundaries transparently.
205
- * See the [Buffer](http://nodejs.org/docs/latest/api/buffer.html) documentation for how these work.
206
- *
207
- * @param offset
208
- */
209
-
210
- readFloatBE: Buffer['readFloatBE'];
211
-
212
- /**
213
- * All of the standard byte-reading methods of the Buffer interface are implemented and will operate across internal Buffer boundaries transparently.
214
- * See the [Buffer](http://nodejs.org/docs/latest/api/buffer.html) documentation for how these work.
215
- *
216
- * @param offset
217
- */
218
-
219
- readFloatLE: Buffer['readFloatLE'];
220
-
221
- /**
222
- * All of the standard byte-reading methods of the Buffer interface are implemented and will operate across internal Buffer boundaries transparently.
223
- * See the [Buffer](http://nodejs.org/docs/latest/api/buffer.html) documentation for how these work.
224
- *
225
- * @param offset
226
- */
227
-
228
- readBigInt64BE: Buffer['readBigInt64BE'];
229
-
230
- /**
231
- * All of the standard byte-reading methods of the Buffer interface are implemented and will operate across internal Buffer boundaries transparently.
232
- * See the [Buffer](http://nodejs.org/docs/latest/api/buffer.html) documentation for how these work.
233
- *
234
- * @param offset
235
- */
236
-
237
- readBigInt64LE: Buffer['readBigInt64LE'];
238
-
239
- /**
240
- * All of the standard byte-reading methods of the Buffer interface are implemented and will operate across internal Buffer boundaries transparently.
241
- * See the [Buffer](http://nodejs.org/docs/latest/api/buffer.html) documentation for how these work.
242
- *
243
- * @param offset
244
- */
245
-
246
- readBigUInt64BE: Buffer['readBigUInt64BE'];
247
-
248
- /**
249
- * All of the standard byte-reading methods of the Buffer interface are implemented and will operate across internal Buffer boundaries transparently.
250
- * See the [Buffer](http://nodejs.org/docs/latest/api/buffer.html) documentation for how these work.
251
- *
252
- * @param offset
253
- */
254
-
255
- readBigUInt64LE: Buffer['readBigUInt64LE'];
256
-
257
- /**
258
- * All of the standard byte-reading methods of the Buffer interface are implemented and will operate across internal Buffer boundaries transparently.
259
- * See the [Buffer](http://nodejs.org/docs/latest/api/buffer.html) documentation for how these work.
260
- *
261
- * @param offset
262
- */
263
-
264
- readInt32BE: Buffer['readInt32BE'];
265
-
266
- /**
267
- * All of the standard byte-reading methods of the Buffer interface are implemented and will operate across internal Buffer boundaries transparently.
268
- * See the [Buffer](http://nodejs.org/docs/latest/api/buffer.html) documentation for how these work.
269
- *
270
- * @param offset
271
- */
272
-
273
- readInt32LE: Buffer['readInt32LE'];
274
-
275
- /**
276
- * All of the standard byte-reading methods of the Buffer interface are implemented and will operate across internal Buffer boundaries transparently.
277
- * See the [Buffer](http://nodejs.org/docs/latest/api/buffer.html) documentation for how these work.
278
- *
279
- * @param offset
280
- */
281
-
282
- readUInt32BE: Buffer['readUInt32BE'];
283
-
284
- /**
285
- * All of the standard byte-reading methods of the Buffer interface are implemented and will operate across internal Buffer boundaries transparently.
286
- * See the [Buffer](http://nodejs.org/docs/latest/api/buffer.html) documentation for how these work.
287
- *
288
- * @param offset
289
- */
290
-
291
- readUInt32LE: Buffer['readUInt32LE'];
292
-
293
- /**
294
- * All of the standard byte-reading methods of the Buffer interface are implemented and will operate across internal Buffer boundaries transparently.
295
- * See the [Buffer](http://nodejs.org/docs/latest/api/buffer.html) documentation for how these work.
296
- *
297
- * @param offset
298
- */
299
-
300
- readInt16BE: Buffer['readInt16BE'];
301
-
302
- /**
303
- * All of the standard byte-reading methods of the Buffer interface are
304
- * implemented and will operate across internal Buffer boundaries transparently.
305
- *
306
- * See the [Buffer](http://nodejs.org/docs/latest/api/buffer.html)
307
- * documentation for how these work.
308
- *
309
- * @param offset
310
- */
311
-
312
- readInt16LE: Buffer['readInt16LE'];
313
-
314
- /**
315
- * All of the standard byte-reading methods of the Buffer interface are
316
- * implemented and will operate across internal Buffer boundaries transparently.
317
- *
318
- * See the [Buffer](http://nodejs.org/docs/latest/api/buffer.html)
319
- * documentation for how these work.
320
- *
321
- * @param offset
322
- */
323
-
324
- readUInt16BE: Buffer['readUInt16BE'];
325
-
326
- /**
327
- * All of the standard byte-reading methods of the Buffer interface are
328
- * implemented and will operate across internal Buffer boundaries transparently.
329
- *
330
- * See the [Buffer](http://nodejs.org/docs/latest/api/buffer.html)
331
- * documentation for how these work.
332
- *
333
- * @param offset
334
- */
335
-
336
- readUInt16LE: Buffer['readUInt16LE'];
337
-
338
- /**
339
- * All of the standard byte-reading methods of the Buffer interface are
340
- * implemented and will operate across internal Buffer boundaries transparently.
341
- *
342
- * See the [Buffer](http://nodejs.org/docs/latest/api/buffer.html)
343
- * documentation for how these work.
344
- *
345
- * @param offset
346
- */
347
-
348
- readInt8: Buffer['readInt8'];
349
-
350
- /**
351
- * All of the standard byte-reading methods of the Buffer interface are
352
- * implemented and will operate across internal Buffer boundaries transparently.
353
- *
354
- * See the [Buffer](http://nodejs.org/docs/latest/api/buffer.html)
355
- * documentation for how these work.
356
- *
357
- * @param offset
358
- */
359
-
360
- readUInt8: Buffer['readUInt8'];
361
-
362
- /**
363
- * All of the standard byte-reading methods of the Buffer interface are
364
- * implemented and will operate across internal Buffer boundaries transparently.
365
- *
366
- * See the [Buffer](http://nodejs.org/docs/latest/api/buffer.html)
367
- * documentation for how these work.
368
- *
369
- * @param offset
370
- */
371
-
372
- readIntBE: Buffer['readIntBE'];
373
-
374
- /**
375
- * All of the standard byte-reading methods of the Buffer interface are
376
- * implemented and will operate across internal Buffer boundaries transparently.
377
- *
378
- * See the [Buffer](http://nodejs.org/docs/latest/api/buffer.html)
379
- * documentation for how these work.
380
- *
381
- * @param offset
382
- */
383
-
384
- readIntLE: Buffer['readIntLE'];
385
-
386
- /**
387
- * All of the standard byte-reading methods of the Buffer interface are
388
- * implemented and will operate across internal Buffer boundaries transparently.
389
- *
390
- * See the [Buffer](http://nodejs.org/docs/latest/api/buffer.html)
391
- * documentation for how these work.
392
- *
393
- * @param offset
394
- */
395
-
396
- readUIntBE: Buffer['readUIntBE'];
397
-
398
- /**
399
- * All of the standard byte-reading methods of the Buffer interface are
400
- * implemented and will operate across internal Buffer boundaries transparently.
401
- *
402
- * See the [Buffer](http://nodejs.org/docs/latest/api/buffer.html)
403
- * documentation for how these work.
404
- *
405
- * @param offset
406
- */
407
-
408
- readUIntLE: Buffer['readUIntLE'];
409
- }
410
-
411
- /**
412
- * No arguments are required for the constructor, but you can initialise
413
- * the list by passing in a single Buffer object or an array of Buffer
414
- * objects.
415
- *
416
- * `new` is not strictly required, if you don't instantiate a new object,
417
- * it will be done automatically for you so you can create a new instance
418
- * simply with:
419
- *
420
- * ```js
421
- * const { BufferList } = require('bl')
422
- * const bl = BufferList()
423
- *
424
- * // equivalent to:
425
- *
426
- * const { BufferList } = require('bl')
427
- * const bl = new BufferList()
428
- * ```
429
- */
430
-
431
- declare const BufferList: BufferListConstructor;
package/bl.js DELETED
@@ -1,84 +0,0 @@
1
- 'use strict'
2
-
3
- const DuplexStream = require('readable-stream').Duplex
4
- const inherits = require('inherits')
5
- const BufferList = require('./BufferList')
6
-
7
- function BufferListStream (callback) {
8
- if (!(this instanceof BufferListStream)) {
9
- return new BufferListStream(callback)
10
- }
11
-
12
- if (typeof callback === 'function') {
13
- this._callback = callback
14
-
15
- const piper = function piper (err) {
16
- if (this._callback) {
17
- this._callback(err)
18
- this._callback = null
19
- }
20
- }.bind(this)
21
-
22
- this.on('pipe', function onPipe (src) {
23
- src.on('error', piper)
24
- })
25
- this.on('unpipe', function onUnpipe (src) {
26
- src.removeListener('error', piper)
27
- })
28
-
29
- callback = null
30
- }
31
-
32
- BufferList._init.call(this, callback)
33
- DuplexStream.call(this)
34
- }
35
-
36
- inherits(BufferListStream, DuplexStream)
37
- Object.assign(BufferListStream.prototype, BufferList.prototype)
38
-
39
- BufferListStream.prototype._new = function _new (callback) {
40
- return new BufferListStream(callback)
41
- }
42
-
43
- BufferListStream.prototype._write = function _write (buf, encoding, callback) {
44
- this._appendBuffer(buf)
45
-
46
- if (typeof callback === 'function') {
47
- callback()
48
- }
49
- }
50
-
51
- BufferListStream.prototype._read = function _read (size) {
52
- if (!this.length) {
53
- return this.push(null)
54
- }
55
-
56
- size = Math.min(size, this.length)
57
- this.push(this.slice(0, size))
58
- this.consume(size)
59
- }
60
-
61
- BufferListStream.prototype.end = function end (chunk) {
62
- DuplexStream.prototype.end.call(this, chunk)
63
-
64
- if (this._callback) {
65
- this._callback(null, this.slice())
66
- this._callback = null
67
- }
68
- }
69
-
70
- BufferListStream.prototype._destroy = function _destroy (err, cb) {
71
- this._bufs.length = 0
72
- this.length = 0
73
- cb(err)
74
- }
75
-
76
- BufferListStream.prototype._isBufferList = function _isBufferList (b) {
77
- return b instanceof BufferListStream || b instanceof BufferList || BufferListStream.isBufferList(b)
78
- }
79
-
80
- BufferListStream.isBufferList = BufferList.isBufferList
81
-
82
- module.exports = BufferListStream
83
- module.exports.BufferListStream = BufferListStream
84
- module.exports.BufferList = BufferList
package/index.d.ts DELETED
@@ -1,88 +0,0 @@
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;