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/.github/dependabot.yml +4 -0
- package/.github/workflows/test-and-release.yml +18 -21
- package/BufferList.js +399 -317
- package/BufferListStream.js +134 -0
- package/CHANGELOG.md +28 -0
- package/README.md +49 -63
- package/package.json +32 -18
- package/test/convert.js +3 -5
- package/test/indexOf.js +3 -5
- package/test/isBufferList.js +3 -5
- package/test/test.js +27 -27
- package/test/types.ts +89 -0
- package/test/verify-types.js +51 -0
- package/tsconfig.json +24 -0
- package/types/BufferList.d.ts +109 -0
- package/types/BufferList.d.ts.map +1 -0
- package/types/BufferListStream.d.ts +54 -0
- package/types/BufferListStream.d.ts.map +1 -0
- package/types/augment.d.ts +50 -0
- package/types/index.d.ts +4 -0
- package/BufferList.d.ts +0 -431
- package/bl.js +0 -84
- package/index.d.ts +0 -88
package/test/types.ts
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
// Type-level test: verifies augmented types are correct.
|
|
2
|
+
// Run with: tsc --noEmit test/types.ts
|
|
3
|
+
// If this file fails to compile, the type augmentations are out of sync.
|
|
4
|
+
|
|
5
|
+
import { BufferListStream, BufferList } from '../types/index.js'
|
|
6
|
+
|
|
7
|
+
// -- Conformance with Buffer read methods --
|
|
8
|
+
// Assert that BufferList's read methods are callable with the same
|
|
9
|
+
// signatures as Buffer's. If @types/node changes a signature, this
|
|
10
|
+
// section will fail to compile.
|
|
11
|
+
type AssertConforms<_Bl extends _Buf, _Buf> = true
|
|
12
|
+
|
|
13
|
+
type _FixedRead = AssertConforms<
|
|
14
|
+
{ [K in
|
|
15
|
+
| 'readDoubleBE' | 'readDoubleLE'
|
|
16
|
+
| 'readFloatBE' | 'readFloatLE'
|
|
17
|
+
| 'readBigInt64BE' | 'readBigInt64LE'
|
|
18
|
+
| 'readBigUInt64BE' | 'readBigUInt64LE'
|
|
19
|
+
| 'readInt32BE' | 'readInt32LE'
|
|
20
|
+
| 'readUInt32BE' | 'readUInt32LE'
|
|
21
|
+
| 'readInt16BE' | 'readInt16LE'
|
|
22
|
+
| 'readUInt16BE' | 'readUInt16LE'
|
|
23
|
+
| 'readInt8' | 'readUInt8'
|
|
24
|
+
]: BufferList[K] },
|
|
25
|
+
{ [K in
|
|
26
|
+
| 'readDoubleBE' | 'readDoubleLE'
|
|
27
|
+
| 'readFloatBE' | 'readFloatLE'
|
|
28
|
+
| 'readBigInt64BE' | 'readBigInt64LE'
|
|
29
|
+
| 'readBigUInt64BE' | 'readBigUInt64LE'
|
|
30
|
+
| 'readInt32BE' | 'readInt32LE'
|
|
31
|
+
| 'readUInt32BE' | 'readUInt32LE'
|
|
32
|
+
| 'readInt16BE' | 'readInt16LE'
|
|
33
|
+
| 'readUInt16BE' | 'readUInt16LE'
|
|
34
|
+
| 'readInt8' | 'readUInt8'
|
|
35
|
+
]: Buffer[K] }
|
|
36
|
+
>
|
|
37
|
+
|
|
38
|
+
type _VariableRead = AssertConforms<
|
|
39
|
+
{ [K in 'readIntBE' | 'readIntLE' | 'readUIntBE' | 'readUIntLE']: BufferList[K] },
|
|
40
|
+
{ [K in 'readIntBE' | 'readIntLE' | 'readUIntBE' | 'readUIntLE']: Buffer[K] }
|
|
41
|
+
>
|
|
42
|
+
|
|
43
|
+
// Verify return types match Buffer
|
|
44
|
+
declare const buf: Buffer
|
|
45
|
+
declare const bl: BufferList
|
|
46
|
+
const _br: ReturnType<typeof buf.readUInt16BE> = bl.readUInt16BE(0)
|
|
47
|
+
const _bbr: ReturnType<typeof buf.readBigInt64BE> = bl.readBigInt64BE(0)
|
|
48
|
+
const _bfr: ReturnType<typeof buf.readDoubleBE> = bl.readDoubleBE(0)
|
|
49
|
+
|
|
50
|
+
// -- BufferList basic API --
|
|
51
|
+
const bl2 = new BufferList()
|
|
52
|
+
const _a1: BufferList = bl2.append(Buffer.from('test'))
|
|
53
|
+
const _a2: BufferList = bl2.prepend(Buffer.from('test'))
|
|
54
|
+
const _g: number | undefined = bl2.get(0)
|
|
55
|
+
const _s: Buffer = bl2.slice(0, 2)
|
|
56
|
+
const _ss: BufferList = bl2.shallowSlice(0, 2)
|
|
57
|
+
const _c: Buffer = bl2.copy(Buffer.alloc(4), 0, 0, 4)
|
|
58
|
+
const _d: BufferList = bl2.duplicate()
|
|
59
|
+
const _co: BufferList = bl2.consume(2)
|
|
60
|
+
const _ts: string = bl2.toString('utf8', 0, 2)
|
|
61
|
+
const _io: number = bl2.indexOf('test')
|
|
62
|
+
const _io2: number = bl2.indexOf(Buffer.from('x'), 0, 'utf8')
|
|
63
|
+
const _gb: Buffer[] = bl2.getBuffers()
|
|
64
|
+
const _l: number = bl2.length
|
|
65
|
+
const _ib: boolean = BufferList.isBufferList(bl2)
|
|
66
|
+
|
|
67
|
+
// -- BufferListStream has both Duplex and BufferList APIs --
|
|
68
|
+
const bls = new BufferListStream()
|
|
69
|
+
const _sa: BufferListStream = bls.append(Buffer.from('test'))
|
|
70
|
+
const _sp: BufferListStream = bls.prepend(Buffer.from('test'))
|
|
71
|
+
const _sg: number | undefined = bls.get(0)
|
|
72
|
+
const _sslice: Buffer = bls.slice(0, 2)
|
|
73
|
+
const _sss: BufferListStream = bls.shallowSlice(0, 2)
|
|
74
|
+
const _sco: BufferListStream = bls.consume(2)
|
|
75
|
+
const _sd: BufferListStream = bls.duplicate()
|
|
76
|
+
const _sts: string = bls.toString('utf8', 0, 2)
|
|
77
|
+
const _sio: number = bls.indexOf('test')
|
|
78
|
+
const _sgb: Buffer[] = bls.getBuffers()
|
|
79
|
+
const _sru: number = bls.readUInt16BE(0)
|
|
80
|
+
const _srb: bigint = bls.readBigInt64BE(0)
|
|
81
|
+
const _srib: number = bls.readIntBE(0, 4)
|
|
82
|
+
|
|
83
|
+
// Duplex stream methods
|
|
84
|
+
bls.pipe(process.stdout)
|
|
85
|
+
bls.write(Buffer.from('hello'))
|
|
86
|
+
bls.end()
|
|
87
|
+
|
|
88
|
+
// isBufferList
|
|
89
|
+
const _sib: boolean = BufferListStream.isBufferList(bls)
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import tape from 'tape'
|
|
2
|
+
import { BufferList, BufferListStream } from '../BufferListStream.js'
|
|
3
|
+
|
|
4
|
+
// Methods declared in types/augment.d.ts for BufferList (read methods)
|
|
5
|
+
const readMethods = [
|
|
6
|
+
'readDoubleBE', 'readDoubleLE',
|
|
7
|
+
'readFloatBE', 'readFloatLE',
|
|
8
|
+
'readBigInt64BE', 'readBigInt64LE',
|
|
9
|
+
'readBigUInt64BE', 'readBigUInt64LE',
|
|
10
|
+
'readInt32BE', 'readInt32LE',
|
|
11
|
+
'readUInt32BE', 'readUInt32LE',
|
|
12
|
+
'readInt16BE', 'readInt16LE',
|
|
13
|
+
'readUInt16BE', 'readUInt16LE',
|
|
14
|
+
'readInt8', 'readUInt8',
|
|
15
|
+
'readIntBE', 'readIntLE',
|
|
16
|
+
'readUIntBE', 'readUIntLE'
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
// Methods declared in types/augment.d.ts for BufferListStream (BufferList methods)
|
|
20
|
+
const bufferListMethods = [
|
|
21
|
+
'append', 'prepend',
|
|
22
|
+
'get', 'indexOf',
|
|
23
|
+
'slice', 'shallowSlice',
|
|
24
|
+
'copy', 'duplicate',
|
|
25
|
+
'consume', 'toString',
|
|
26
|
+
'getBuffers'
|
|
27
|
+
]
|
|
28
|
+
|
|
29
|
+
tape('BufferList has all augmented read methods', (t) => {
|
|
30
|
+
const bl = new BufferList()
|
|
31
|
+
for (const method of readMethods) {
|
|
32
|
+
t.equal(typeof bl[method], 'function', `BufferList.prototype.${method} exists`)
|
|
33
|
+
}
|
|
34
|
+
t.end()
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
tape('BufferListStream has all augmented read methods', (t) => {
|
|
38
|
+
const bls = new BufferListStream()
|
|
39
|
+
for (const method of readMethods) {
|
|
40
|
+
t.equal(typeof bls[method], 'function', `BufferListStream.prototype.${method} exists`)
|
|
41
|
+
}
|
|
42
|
+
t.end()
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
tape('BufferListStream has all augmented BufferList methods', (t) => {
|
|
46
|
+
const bls = new BufferListStream()
|
|
47
|
+
for (const method of bufferListMethods) {
|
|
48
|
+
t.equal(typeof bls[method], 'function', `BufferListStream.prototype.${method} exists`)
|
|
49
|
+
}
|
|
50
|
+
t.end()
|
|
51
|
+
})
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"allowJs": true,
|
|
4
|
+
"checkJs": true,
|
|
5
|
+
"strict": true,
|
|
6
|
+
"esModuleInterop": true,
|
|
7
|
+
"target": "ESNext",
|
|
8
|
+
"module": "nodenext",
|
|
9
|
+
"moduleResolution": "nodenext",
|
|
10
|
+
"skipLibCheck": true,
|
|
11
|
+
"types": ["node"],
|
|
12
|
+
"declaration": true,
|
|
13
|
+
"declarationMap": true,
|
|
14
|
+
"emitDeclarationOnly": true,
|
|
15
|
+
"outDir": "types"
|
|
16
|
+
},
|
|
17
|
+
"include": [
|
|
18
|
+
"BufferList.js",
|
|
19
|
+
"BufferListStream.js"
|
|
20
|
+
],
|
|
21
|
+
"exclude": [
|
|
22
|
+
"node_modules"
|
|
23
|
+
]
|
|
24
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
export class BufferList {
|
|
2
|
+
/**
|
|
3
|
+
* @param {any} b
|
|
4
|
+
* @returns {boolean}
|
|
5
|
+
*/
|
|
6
|
+
static isBufferList(b: any): boolean;
|
|
7
|
+
/** @param {BufferListAcceptedTypes} [buf] */
|
|
8
|
+
constructor(buf?: BufferListAcceptedTypes);
|
|
9
|
+
/** @type {Buffer[]} */
|
|
10
|
+
_bufs: Buffer[];
|
|
11
|
+
/** @type {number} */
|
|
12
|
+
length: number;
|
|
13
|
+
/** @param {BufferListAcceptedTypes} [buf] */
|
|
14
|
+
_new(buf?: BufferListAcceptedTypes): BufferList;
|
|
15
|
+
/**
|
|
16
|
+
* @param {number} offset
|
|
17
|
+
* @returns {[number, number]}
|
|
18
|
+
*/
|
|
19
|
+
_offset(offset: number): [number, number];
|
|
20
|
+
/**
|
|
21
|
+
* @param {[number, number]} blOffset
|
|
22
|
+
* @returns {number}
|
|
23
|
+
*/
|
|
24
|
+
_reverseOffset(blOffset: [number, number]): number;
|
|
25
|
+
/** @returns {Buffer[]} */
|
|
26
|
+
getBuffers(): Buffer[];
|
|
27
|
+
/**
|
|
28
|
+
* @param {number} index
|
|
29
|
+
* @returns {number | undefined}
|
|
30
|
+
*/
|
|
31
|
+
get(index: number): number | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* @param {number} [start]
|
|
34
|
+
* @param {number} [end]
|
|
35
|
+
* @returns {Buffer}
|
|
36
|
+
*/
|
|
37
|
+
slice(start?: number, end?: number): Buffer;
|
|
38
|
+
/**
|
|
39
|
+
* @param {Buffer | null} dst
|
|
40
|
+
* @param {number} [dstStart]
|
|
41
|
+
* @param {number} [srcStart]
|
|
42
|
+
* @param {number} [srcEnd]
|
|
43
|
+
* @returns {Buffer}
|
|
44
|
+
*/
|
|
45
|
+
copy(dst: Buffer | null, dstStart?: number, srcStart?: number, srcEnd?: number): Buffer;
|
|
46
|
+
/**
|
|
47
|
+
* @param {number} [start]
|
|
48
|
+
* @param {number} [end]
|
|
49
|
+
* @returns {BufferList}
|
|
50
|
+
*/
|
|
51
|
+
shallowSlice(start?: number, end?: number): BufferList;
|
|
52
|
+
/**
|
|
53
|
+
* @param {BufferEncoding} [encoding]
|
|
54
|
+
* @param {number} [start]
|
|
55
|
+
* @param {number} [end]
|
|
56
|
+
* @returns {string}
|
|
57
|
+
*/
|
|
58
|
+
toString(encoding?: BufferEncoding, start?: number, end?: number): string;
|
|
59
|
+
/**
|
|
60
|
+
* @param {number} bytes
|
|
61
|
+
* @returns {this}
|
|
62
|
+
*/
|
|
63
|
+
consume(bytes: number): this;
|
|
64
|
+
/** @returns {BufferList} */
|
|
65
|
+
duplicate(): BufferList;
|
|
66
|
+
/**
|
|
67
|
+
* @param {BufferListAcceptedTypes} buf
|
|
68
|
+
* @returns {this}
|
|
69
|
+
*/
|
|
70
|
+
append(buf: BufferListAcceptedTypes): this;
|
|
71
|
+
/**
|
|
72
|
+
* @param {BufferListAcceptedTypes} buf
|
|
73
|
+
* @returns {this}
|
|
74
|
+
*/
|
|
75
|
+
prepend(buf: BufferListAcceptedTypes): this;
|
|
76
|
+
/**
|
|
77
|
+
* @param {BufferListAcceptedTypes} buf
|
|
78
|
+
* @param {(this: BufferList, buf: Buffer) => void} attacher
|
|
79
|
+
* @param {boolean} [prepend]
|
|
80
|
+
* @returns {this}
|
|
81
|
+
*/
|
|
82
|
+
_attach(buf: BufferListAcceptedTypes, attacher: (this: BufferList, buf: Buffer) => void, prepend?: boolean): this;
|
|
83
|
+
/** @param {Buffer} buf */
|
|
84
|
+
_appendBuffer(buf: Buffer): void;
|
|
85
|
+
/** @param {Buffer} buf */
|
|
86
|
+
_prependBuffer(buf: Buffer): void;
|
|
87
|
+
/**
|
|
88
|
+
* @param {string | number | Buffer | BufferList | Uint8Array} search
|
|
89
|
+
* @param {number | string} [offset]
|
|
90
|
+
* @param {BufferEncoding} [encoding]
|
|
91
|
+
* @returns {number}
|
|
92
|
+
*/
|
|
93
|
+
indexOf(search: string | number | Buffer | BufferList | Uint8Array, offset?: number | string, encoding?: BufferEncoding): number;
|
|
94
|
+
/**
|
|
95
|
+
* @param {number} offset
|
|
96
|
+
* @param {Buffer | Uint8Array} search
|
|
97
|
+
* @returns {boolean}
|
|
98
|
+
*/
|
|
99
|
+
_match(offset: number, search: Buffer | Uint8Array): boolean;
|
|
100
|
+
/**
|
|
101
|
+
* @param {any} b
|
|
102
|
+
* @returns {b is BufferList}
|
|
103
|
+
*/
|
|
104
|
+
_isBufferList(b: any): b is BufferList;
|
|
105
|
+
}
|
|
106
|
+
export default BufferList;
|
|
107
|
+
export type BufferListAcceptedTypes = Buffer | BufferList | Uint8Array | Array<Buffer | BufferList | Uint8Array | string | number> | string | number;
|
|
108
|
+
import { Buffer } from 'node:buffer';
|
|
109
|
+
//# sourceMappingURL=BufferList.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BufferList.d.ts","sourceRoot":"","sources":["../BufferList.js"],"names":[],"mappings":"AAQA;IA6bE;;;OAGG;IACH,uBAHW,GAAG,GACD,OAAO,CAInB;IAlcD,6CAA6C;IAC7C,kBADY,uBAAuB,EAUlC;IARC,uBAAuB;IACvB,OADW,MAAM,EAAE,CACJ;IACf,qBAAqB;IACrB,QADW,MAAM,CACF;IAOjB,6CAA6C;IAC7C,WADY,uBAAuB,cAGlC;IAED;;;OAGG;IACH,gBAHW,MAAM,GACJ,CAAC,MAAM,EAAE,MAAM,CAAC,CAkB5B;IAED;;;OAGG;IACH,yBAHW,CAAC,MAAM,EAAE,MAAM,CAAC,GACd,MAAM,CAWlB;IAED,0BAA0B;IAC1B,cADc,MAAM,EAAE,CAGrB;IAED;;;OAGG;IACH,WAHW,MAAM,GACJ,MAAM,GAAG,SAAS,CAU9B;IAED;;;;OAIG;IACH,cAJW,MAAM,QACN,MAAM,GACJ,MAAM,CAYlB;IAED;;;;;;OAMG;IACH,UANW,MAAM,GAAG,IAAI,aACb,MAAM,aACN,MAAM,WACN,MAAM,GACJ,MAAM,CAoFlB;IAED;;;;OAIG;IACH,qBAJW,MAAM,QACN,MAAM,GACJ,UAAU,CAiCtB;IAED;;;;;OAKG;IACH,oBALW,cAAc,UACd,MAAM,QACN,MAAM,GACJ,MAAM,CAIlB;IAED;;;OAGG;IACH,eAHW,MAAM,GACJ,IAAI,CAqBhB;IAED,4BAA4B;IAC5B,aADc,UAAU,CASvB;IAED;;;OAGG;IACH,YAHW,uBAAuB,GACrB,IAAI,CAIhB;IAED;;;OAGG;IACH,aAHW,uBAAuB,GACrB,IAAI,CAIhB;IAED;;;;;OAKG;IACH,aALW,uBAAuB,YACvB,CAAC,IAAI,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI,YACvC,OAAO,GACL,IAAI,CAmChB;IAED,0BAA0B;IAC1B,mBADY,MAAM,QAIjB;IAED,0BAA0B;IAC1B,oBADY,MAAM,QAIjB;IAED;;;;;OAKG;IACH,gBALW,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,UAAU,GAAG,UAAU,WAClD,MAAM,GAAG,MAAM,aACf,cAAc,GACZ,MAAM,CA0ElB;IAED;;;;OAIG;IACH,eAJW,MAAM,UACN,MAAM,GAAG,UAAU,GACjB,OAAO,CAanB;IAMD;;;OAGG;IACH,iBAHW,GAAG,GACD,CAAC,IAAI,UAAU,CAI3B;CASF;;sCAzcY,MAAM,GAAG,UAAU,GAAG,UAAU,GAAG,KAAK,CAAC,MAAM,GAAG,UAAU,GAAG,UAAU,GAAG,MAAM,GAAG,MAAM,CAAC,GAAG,MAAM,GAAG,MAAM;uBAHpG,aAAa"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {import('./BufferList.js').BufferListAcceptedTypes} BufferListAcceptedTypes
|
|
3
|
+
*/
|
|
4
|
+
export class BufferListStream extends Duplex {
|
|
5
|
+
/**
|
|
6
|
+
* @param {any} b
|
|
7
|
+
* @returns {boolean}
|
|
8
|
+
*/
|
|
9
|
+
static isBufferList(b: any): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* @param {((err: Error | null, buffer?: Buffer) => void) | BufferListAcceptedTypes} [callback]
|
|
12
|
+
*/
|
|
13
|
+
constructor(callback?: ((err: Error | null, buffer?: Buffer) => void) | BufferListAcceptedTypes);
|
|
14
|
+
_callback: ((err: Error | null, buffer?: Buffer) => void) | undefined;
|
|
15
|
+
/** @type {Buffer[]} */
|
|
16
|
+
_bufs: Buffer[];
|
|
17
|
+
/** @type {number} */
|
|
18
|
+
length: number;
|
|
19
|
+
/**
|
|
20
|
+
* @param {any} buf
|
|
21
|
+
* @param {string} encoding
|
|
22
|
+
* @param {Function} callback
|
|
23
|
+
*/
|
|
24
|
+
_write(buf: any, encoding: string, callback: Function): void;
|
|
25
|
+
/** @param {number} size */
|
|
26
|
+
_read(size: number): boolean | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* @param {any} [chunk]
|
|
29
|
+
* @param {any} [encoding]
|
|
30
|
+
* @param {any} [cb]
|
|
31
|
+
* @returns {this}
|
|
32
|
+
*/
|
|
33
|
+
end(chunk?: any, encoding?: any, cb?: any): this;
|
|
34
|
+
/**
|
|
35
|
+
* @param {Error | null} err
|
|
36
|
+
* @param {Function} cb
|
|
37
|
+
*/
|
|
38
|
+
_destroy(err: Error | null, cb: Function): void;
|
|
39
|
+
/** @param {any} [callback] */
|
|
40
|
+
_new(callback?: any): BufferListStream;
|
|
41
|
+
/**
|
|
42
|
+
* @param {any} b
|
|
43
|
+
* @returns {b is BufferList}
|
|
44
|
+
*/
|
|
45
|
+
_isBufferList(b: any): b is BufferList;
|
|
46
|
+
}
|
|
47
|
+
export default BufferListStream;
|
|
48
|
+
export { BufferList };
|
|
49
|
+
/** @type {(b: any) => boolean} */
|
|
50
|
+
export const isBufferList: (b: any) => boolean;
|
|
51
|
+
export type BufferListAcceptedTypes = import("./BufferList.js").BufferListAcceptedTypes;
|
|
52
|
+
import { Duplex } from 'node:stream';
|
|
53
|
+
import { BufferList } from './BufferList.js';
|
|
54
|
+
//# sourceMappingURL=BufferListStream.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BufferListStream.d.ts","sourceRoot":"","sources":["../BufferListStream.js"],"names":[],"mappings":"AAKA;;GAEG;AAEH;IAuGE;;;OAGG;IACH,uBAHW,GAAG,GACD,OAAO,CAInB;IA5GD;;OAEG;IACH,uBAFW,CAAC,CAAC,GAAG,EAAE,KAAK,GAAG,IAAI,EAAE,MAAM,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC,GAAG,uBAAuB,EAmClF;IA7BG,kBANc,KAAK,GAAG,IAAI,WAAW,MAAM,KAAK,IAAI,cAM3B;IAqB3B,uBAAuB;IACvB,OADW,MAAM,EAAE,CACJ;IACf,qBAAqB;IACrB,QADW,MAAM,CACF;IAOjB;;;;OAIG;IACH,YAJW,GAAG,YACH,MAAM,4BAQhB;IAED,2BAA2B;IAC3B,YADY,MAAM,uBAUjB;IAED;;;;;OAKG;IACH,YALW,GAAG,aACH,GAAG,OACH,GAAG,GACD,IAAI,CAWhB;IAED;;;OAGG;IACH,cAHW,KAAK,GAAG,IAAI,sBAOtB;IAED,8BAA8B;IAC9B,gBADY,GAAG,oBAGd;IAED;;;OAGG;IACH,iBAHW,GAAG,GACD,CAAC,IAAI,UAAU,CAI3B;CASF;;;AAaD,kCAAkC;AAClC,2BADW,CAAC,CAAC,EAAE,GAAG,KAAK,OAAO,CACqB;sCA/HtC,OAAO,iBAAiB,EAAE,uBAAuB;uBANvC,aAAa;2BACT,iBAAiB"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { BufferList, BufferListAcceptedTypes } from './BufferList.js'
|
|
2
|
+
|
|
3
|
+
// Buffer read methods dynamically assigned to BufferList.prototype
|
|
4
|
+
interface BufferListReadMethods {
|
|
5
|
+
readDoubleBE(offset?: number): number
|
|
6
|
+
readDoubleLE(offset?: number): number
|
|
7
|
+
readFloatBE(offset?: number): number
|
|
8
|
+
readFloatLE(offset?: number): number
|
|
9
|
+
readBigInt64BE(offset?: number): bigint
|
|
10
|
+
readBigInt64LE(offset?: number): bigint
|
|
11
|
+
readBigUInt64BE(offset?: number): bigint
|
|
12
|
+
readBigUInt64LE(offset?: number): bigint
|
|
13
|
+
readInt32BE(offset?: number): number
|
|
14
|
+
readInt32LE(offset?: number): number
|
|
15
|
+
readUInt32BE(offset?: number): number
|
|
16
|
+
readUInt32LE(offset?: number): number
|
|
17
|
+
readInt16BE(offset?: number): number
|
|
18
|
+
readInt16LE(offset?: number): number
|
|
19
|
+
readUInt16BE(offset?: number): number
|
|
20
|
+
readUInt16LE(offset?: number): number
|
|
21
|
+
readInt8(offset?: number): number
|
|
22
|
+
readUInt8(offset?: number): number
|
|
23
|
+
readIntBE(offset: number, byteLength: number): number
|
|
24
|
+
readIntLE(offset: number, byteLength: number): number
|
|
25
|
+
readUIntBE(offset: number, byteLength: number): number
|
|
26
|
+
readUIntLE(offset: number, byteLength: number): number
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// BufferList methods copied to BufferListStream.prototype at runtime
|
|
30
|
+
interface BufferListMethods {
|
|
31
|
+
append(buf: BufferListAcceptedTypes): this
|
|
32
|
+
prepend(buf: BufferListAcceptedTypes): this
|
|
33
|
+
get(index: number): number | undefined
|
|
34
|
+
indexOf(search: string | number | Buffer | BufferList | Uint8Array, offset?: number | string, encoding?: BufferEncoding): number
|
|
35
|
+
slice(start?: number, end?: number): Buffer
|
|
36
|
+
shallowSlice(start?: number, end?: number): this
|
|
37
|
+
copy(dst: Buffer | null, dstStart?: number, srcStart?: number, srcEnd?: number): Buffer
|
|
38
|
+
duplicate(): this
|
|
39
|
+
consume(bytes: number): this
|
|
40
|
+
toString(encoding?: BufferEncoding, start?: number, end?: number): string
|
|
41
|
+
getBuffers(): Buffer[]
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
declare module './BufferList.js' {
|
|
45
|
+
interface BufferList extends BufferListReadMethods {}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
declare module './BufferListStream.js' {
|
|
49
|
+
interface BufferListStream extends BufferListMethods, BufferListReadMethods {}
|
|
50
|
+
}
|
package/types/index.d.ts
ADDED