Options
All
  • Public
  • Public/Protected
  • All
Menu

Class HazelBuffer

Hierarchy

  • HazelBuffer

Index

Methods

[iterator]

  • [iterator](): Generator<number, void, unknown>

compare

  • Check whether two hazel buffers contain the same information.

    example
    const writer = HazelWriter.alloc(2);
    writer.uint8(21);
    writer.uint8(69);
    
    const writer2 = HazelWriter.alloc(2);
    writer.uint8(21);
    writer.uint8(69);
    
    console.log(writer.compare(writer2)); // => true
    
    writer2.uint8(90);
    
    console.log(writer.compare(writer2)); // => false
    

    Parameters

    Returns boolean

    Whether or not the hazel writers are the same.

goto

  • Move the cursor to a position.

    example
    const writer = HazelWriter.alloc(12);
    writer.goto(5);
    
    console.log(writer.cursor); // => 5
    

    Parameters

    • pos: number

      The position to move to.

    Returns HazelBuffer

    The writer.

jump

  • Skip a speciied number of bytes.

    example
    const writer = HazelWriter.alloc(12);
    writer.skip(3);
    writer.skip(2);
    writer.skip(5);
    
    console.log(writer.cursor); // => 10
    

    Parameters

    • bytes: number

    Returns HazelBuffer

    The writer.

toString

  • toString(encoding?: BufferEncoding): string

Accessors

buffer

  • get buffer(): Buffer
  • The buffer that the writer or reader is targeting.

    example
    const writer = HazelWriter.alloc(6);
    
    console.log(writer; // => <HazelBuffer [00] 00 00 00 00 00>
    

    Returns Buffer

cursor

  • get cursor(): number
  • The current position of the writer or reader.

    example
    const writer = HazelWriter.alloc(2);
    writer.uint16(4);
    
    console.log(writer.cursor); // => 2
    

    Returns number

left

  • get left(): number
  • The number of bytes left in the writer or reader.

    example
    const writer = HazelWriter.alloc(6);
    writer.uint16(4);
    
    console.log(writer.left); // => 4
    

    Returns number

size

  • get size(): number
  • The size of the buffer that the writer or reader is targeting.

    example
    const writer = HazelWriter.alloc(6);
    
    console.log(writer.size); // => 6
    

    Returns number

Generated using TypeDoc