bytes

package
v3.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 18, 2024 License: MIT, Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewBuffer

func NewBuffer(call goja.ConstructorCall, runtime *goja.Runtime) *goja.Object

NewBuffer creates a new buffer from a byte slice.

Types

type Buffer

type Buffer struct {
	// contains filtered or unexported fields
}

Buffer is a bytes/Uint8Array type in javascript @example ```javascript const bytes = require('nuclei/bytes'); const bytes = new bytes.Buffer(); ``` @example ```javascript const bytes = require('nuclei/bytes'); // optionally it can accept existing byte/Uint8Array as input const bytes = new bytes.Buffer([1, 2, 3]); ```

func (*Buffer) Bytes

func (b *Buffer) Bytes() []byte

Bytes returns the byte representation of the buffer. @example ```javascript const bytes = require('nuclei/bytes'); const buffer = new bytes.Buffer(); buffer.WriteString('hello'); log(buffer.Bytes()); ```

func (*Buffer) Hex

func (b *Buffer) Hex() string

Hex returns the hex representation of the buffer. @example ```javascript const bytes = require('nuclei/bytes'); const buffer = new bytes.Buffer(); buffer.WriteString('hello'); log(buffer.Hex()); ```

func (*Buffer) Hexdump

func (b *Buffer) Hexdump() string

Hexdump returns the hexdump representation of the buffer. @example ```javascript const bytes = require('nuclei/bytes'); const buffer = new bytes.Buffer(); buffer.WriteString('hello'); log(buffer.Hexdump()); ```

func (*Buffer) Len

func (b *Buffer) Len() int

Len returns the length of the buffer. @example ```javascript const bytes = require('nuclei/bytes'); const buffer = new bytes.Buffer(); buffer.WriteString('hello'); log(buffer.Len()); ```

func (*Buffer) Pack

func (b *Buffer) Pack(formatStr string, msg any) error

Pack uses structs.Pack and packs given data and appends it to the buffer. it packs the data according to the given format. @example ```javascript const bytes = require('nuclei/bytes'); const buffer = new bytes.Buffer(); buffer.Pack('I', 123); ```

func (*Buffer) String

func (b *Buffer) String() string

String returns the string representation of the buffer. @example ```javascript const bytes = require('nuclei/bytes'); const buffer = new bytes.Buffer(); buffer.WriteString('hello'); log(buffer.String()); ```

func (*Buffer) Write

func (b *Buffer) Write(data []byte) *Buffer

Write appends the given data to the buffer. @example ```javascript const bytes = require('nuclei/bytes'); const buffer = new bytes.Buffer(); buffer.Write([1, 2, 3]); ```

func (*Buffer) WriteString

func (b *Buffer) WriteString(data string) *Buffer

WriteString appends the given string data to the buffer. @example ```javascript const bytes = require('nuclei/bytes'); const buffer = new bytes.Buffer(); buffer.WriteString('hello'); ```

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL