Methods
Bytes() → {Uint8Array}
Bytes returns the byte slice of the buffer.
- Source
Returns:
- The byte slice of the buffer.
- Type:
- Uint8Array
Example
let m = require('nuclei/bytes');
let b = m.Buffer();
let bytes = b.Bytes();
Hex() → {string}
Hex returns the hex representation of the buffer.
- Source
Returns:
- The hex representation of the buffer.
- Type:
- string
Example
let m = require('nuclei/bytes');
let b = m.Buffer();
let hex = b.Hex();
Hexdump() → {string}
Hexdump returns the hexdump representation of the buffer.
- Source
Returns:
- The hexdump representation of the buffer.
- Type:
- string
Example
let m = require('nuclei/bytes');
let b = m.Buffer();
let hexdump = b.Hexdump();
Len() → {number}
Len returns the length of the buffer.
- Source
Returns:
- The length of the buffer.
- Type:
- number
Example
let m = require('nuclei/bytes');
let b = m.Buffer();
let length = b.Len();
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.
Parameters:
Name | Type | Description |
---|---|---|
formatStr | string | The format string to pack the data. |
msg | string | The message to pack. |
- Source
Throws:
- - The error encountered during packing.
- Type
- error
Returns:
- The buffer after packing the data.
- Type:
- Buffer
Example
let m = require('nuclei/bytes');
let b = m.Buffer();
b.Pack('format', 'message');
String() → {string}
String returns the string representation of the buffer.
- Source
Returns:
- The string representation of the buffer.
- Type:
- string
Example
let m = require('nuclei/bytes');
let b = m.Buffer();
let str = b.String();
Write(data) → {Buffer}
Write appends a byte slice to the buffer.
Parameters:
Name | Type | Description |
---|---|---|
data | Uint8Array | The byte slice to append to the buffer. |
- Source
Returns:
- The buffer after appending the byte slice.
- Type:
- Buffer
Example
let m = require('nuclei/bytes');
let b = m.Buffer();
b.Write(new Uint8Array([1, 2, 3]));
WriteString(data) → {Buffer}
WriteString appends a string to the buffer.
Parameters:
Name | Type | Description |
---|---|---|
data | string | The string to append to the buffer. |
- Source
Returns:
- The buffer after appending the string.
- Type:
- Buffer
Example
let m = require('nuclei/bytes');
let b = m.Buffer();
b.WriteString('data');