Skip to main content

类: Buffer

bytes.Buffer Buffer 是 JavaScript 中的byte/Uint8Array 类型 Example
const bytes = require('nuclei/bytes');
const bytes = new bytes.Buffer();
Example
const bytes = require('nuclei/bytes');
// 可选地,它可以接受现有的byte/Uint8Array 作为输入
const bytes = new bytes.Buffer([1, 2, 3]);

目录

构造函数

方法

构造函数

constructor

new Buffer(): Buffer

返回

Buffer

定义于

bytes.ts:21

方法

Bytes

Bytes(): Uint8Array Bytes 返回缓冲区的字节表示。

返回

Uint8Array Example
const bytes = require('nuclei/bytes');
const buffer = new bytes.Buffer();
buffer.WriteString('hello');
log(buffer.Bytes());

定义于

bytes.ts:60

Hex

Hex(): string Hex 返回缓冲区的十六进制表示。

返回

string Example
const bytes = require('nuclei/bytes');
const buffer = new bytes.Buffer();
buffer.WriteString('hello');
log(buffer.Hex());

定义于

bytes.ts:105

Hexdump

Hexdump(): string Hexdump 返回缓冲区的十六进制转储表示。

返回

string Example
const bytes = require('nuclei/bytes');
const buffer = new bytes.Buffer();
buffer.WriteString('hello');
log(buffer.Hexdump());

定义于

bytes.ts:120

Len

Len(): number Len 返回缓冲区的长度。

返回

number Example
const bytes = require('nuclei/bytes');
const buffer = new bytes.Buffer();
buffer.WriteString('hello');
log(buffer.Len());

定义于

bytes.ts:90

Pack

Pack(formatStr, msg): void Pack 使用 structs.Pack 并打包给定的数据,然后将其附加到缓冲区。 它根据给定的格式打包数据。

参数

名称类型
formatStrstring
msgany

返回

void Example
const bytes = require('nuclei/bytes');
const buffer = new bytes.Buffer();
buffer.Pack('I', 123);

定义于

bytes.ts:135

String

String(): string String 返回缓冲区的字符串表示。

返回

string Example
const bytes = require('nuclei/bytes');
const buffer = new bytes.Buffer();
buffer.WriteString('hello');
log(buffer.String());

定义于

bytes.ts:75

Write

Write(data): Buffer Write 将给定的数据附加到缓冲区。

参数

名称类型
dataUint8Array

返回

Buffer Example
const bytes = require('nuclei/bytes');
const buffer = new bytes.Buffer();
buffer.Write([1, 2, 3]);

定义于

bytes.ts:31

WriteString

WriteString(data): Buffer WriteString 将给定的字符串数据附加到缓冲区。

参数

名称类型
datastring

返回

Buffer Example
const bytes = require('nuclei/bytes');
const buffer = new bytes.Buffer();
buffer.WriteString('hello');

定义于

bytes.ts:45