Class HazelBuffer

Hierarchy

Methods

  • Returns Generator<number, void, unknown>

  • Check whether two hazel buffers contain the same information.

    Returns

    Whether or not the hazel writers are the same.

    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

  • Move the cursor to a position.

    Returns

    The writer.

    Example

    const writer = HazelWriter.alloc(12);
    writer.goto(5);

    console.log(writer.cursor); // => 5

    Parameters

    • pos: number

      The position to move to.

    Returns HazelBuffer

  • Skip a speciied number of bytes.

    Returns

    The writer.

    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

  • Parameters

    • Optional encoding: BufferEncoding

    Returns string

Accessors

  • 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

  • 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

  • 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

  • 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