bytes

(bytes).Buffer

Buffer is a minimal buffer implementation to store and retrieve data

Kind: inner class of bytes

buffer.Bytes() ⇒ Uint8Array

Bytes returns the byte slice of the buffer.

Kind: instance method of Buffer
Returns: Uint8Array - - The byte slice of the buffer.
Example

let m = require('nuclei/bytes');
let b = m.Buffer();
let bytes = b.Bytes();

buffer.Hex() ⇒ string

Hex returns the hex representation of the buffer.

Kind: instance method of Buffer
Returns: string - - The hex representation of the buffer.
Example

let m = require('nuclei/bytes');
let b = m.Buffer();
let hex = b.Hex();

buffer.Hexdump() ⇒ string

Hexdump returns the hexdump representation of the buffer.

Kind: instance method of Buffer
Returns: string - - The hexdump representation of the buffer.
Example

let m = require('nuclei/bytes');
let b = m.Buffer();
let hexdump = b.Hexdump();

buffer.Len() ⇒ number

Len returns the length of the buffer.

Kind: instance method of Buffer
Returns: number - - The length of the buffer.
Example

let m = require('nuclei/bytes');
let b = m.Buffer();
let length = b.Len();

buffer.Pack(formatStr, msg) ⇒ Buffer

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

Kind: instance method of Buffer
Returns: Buffer - - The buffer after packing the data.
Throws:

  • error - The error encountered during packing.
ParamTypeDescription
formatStrstringThe format string to pack the data.
msgstringThe message to pack.

Example

let m = require('nuclei/bytes');
let b = m.Buffer();
b.Pack('format', 'message');

buffer.String() ⇒ string

String returns the string representation of the buffer.

Kind: instance method of Buffer
Returns: string - - The string representation of the buffer.
Example

let m = require('nuclei/bytes');
let b = m.Buffer();
let str = b.String();

buffer.Write(data) ⇒ Buffer

Write appends a byte slice to the buffer.

Kind: instance method of Buffer
Returns: Buffer - - The buffer after appending the byte slice.

ParamTypeDescription
dataUint8ArrayThe byte slice to append to the buffer.

Example

let m = require('nuclei/bytes');
let b = m.Buffer();
b.Write(new Uint8Array([1, 2, 3]));

buffer.WriteString(data) ⇒ Buffer

WriteString appends a string to the buffer.

Kind: instance method of Buffer
Returns: Buffer - - The buffer after appending the string.

ParamTypeDescription
datastringThe string to append to the buffer.

Example

let m = require('nuclei/bytes');
let b = m.Buffer();
b.WriteString('data');

(bytes).NewBuffer(call) ⇒ Buffer

NewBuffer creates a new buffer from a byte slice.

Kind: inner method of bytes
Returns: Buffer - - The new buffer created from the byte slice.

ParamTypeDescription
callUint8ArrayThe byte slice to create the buffer from.

Example

let m = require('nuclei/bytes'); 
let buffer = m.NewBuffer(new Uint8Array([1, 2, 3]));