Skip to main content
Module

x/net/mod.ts>Packet

A networking framework that aims to enable the development of complex multi-port servers and clients.
Go to Latest
class Packet
import { Packet } from "https://deno.land/x/net@v1.0.4/mod.ts";

Packet is a structured string of bytes that serves to facilitate communication between client and server.

Constructors

new
Packet(bytes?: Uint8Array | undefined)

Creates a new Packet.

Properties

private
bytes: Array<number>
private
cachedBuffer: Uint8Array | undefined
readonly
buffer: Uint8Array

Gets the bytes of the Packet.

Methods

emptify(): void

Empties the Packet.

merge(packet: Packet): void

Merges the given Packet into this Packet.

mergeU8Array(array: Uint8Array): void

Merges the Uint8Array into the Packet.

readBoolean(): boolean
readByte(): number
readInt(): number
readObject(): Record<string, unknown>
readShort(): number
readUTF(): string
writeBoolean(value: boolean): void

Writes a boolean to the Packet.

writeByte(value: number): void

Writes a byte to the Packet.

writeInt(value: number): void

Writes an int to the Packet.

writeObject(object: Record<string, unknown>, seen?: Set<unknown>): void

Deep serializes the given object into a Packet. Only will serialize keys that have value types of number, boolean, string, or object. Also ignores prototype properties.

writeShort(value: number): void

Writes a short to the Packet.

writeUTF(value: string): void

Writes a UTF string to the Packet.

[Symbol.iterator](): Iterator<number>