Class: Buffer

bytes.Buffer

Buffer is a bytes/Uint8Array type in javascript

Example

const bytes = require('nuclei/bytes');
const bytes = new bytes.Buffer();

Example

const bytes = require('nuclei/bytes');
// optionally it can accept existing byte/Uint8Array as input
const bytes = new bytes.Buffer([1, 2, 3]);

Table of contents

Constructors

Methods

Constructors

constructor

new Buffer(): Buffer

Returns

Buffer

Defined in

bytes.ts:21

Methods

Bytes

Bytes(): Uint8Array

Bytes returns the byte representation of the buffer.

Returns

Uint8Array

Example

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

Defined in

bytes.ts:60


Hex

Hex(): string

Hex returns the hex representation of the buffer.

Returns

string

Example

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

Defined in

bytes.ts:105


Hexdump

Hexdump(): string

Hexdump returns the hexdump representation of the buffer.

Returns

string

Example

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

Defined in

bytes.ts:120


Len

Len(): number

Len returns the length of the buffer.

Returns

number

Example

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

Defined in

bytes.ts:90


Pack

Pack(formatStr, msg): void

Pack uses structs.Pack and packs given data and appends it to the buffer. it packs the data according to the given format.

Parameters

NameType
formatStrstring
msgany

Returns

void

Example

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

Defined in

bytes.ts:135


String

String(): string

String returns the string representation of the buffer.

Returns

string

Example

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

Defined in

bytes.ts:75


Write

Write(data): Buffer

Write appends the given data to the buffer.

Parameters

NameType
dataUint8Array

Returns

Buffer

Example

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

Defined in

bytes.ts:31


WriteString

WriteString(data): Buffer

WriteString appends the given string data to the buffer.

Parameters

NameType
datastring

Returns

Buffer

Example

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

Defined in

bytes.ts:45