skeldjs
    Preparing search index...

    Class HazelBuffer

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    _buffer: Buffer
    _cursor: number

    Accessors

    • get buffer(): Buffer<ArrayBufferLike>

      The buffer that the writer or reader is targeting.

      Returns Buffer<ArrayBufferLike>

      const writer = HazelWriter.alloc(6);

      console.log(writer; // => <HazelBuffer [00] 00 00 00 00 00>
    • get cursor(): number

      The current position of the writer or reader.

      Returns number

      const writer = HazelWriter.alloc(2);
      writer.uint16(4);

      console.log(writer.cursor); // => 2
    • get left(): number

      The number of bytes left in the writer or reader.

      Returns number

      const writer = HazelWriter.alloc(6);
      writer.uint16(4);

      console.log(writer.left); // => 4
    • get size(): number

      The size of the buffer that the writer or reader is targeting.

      Returns number

      const writer = HazelWriter.alloc(6);

      console.log(writer.size); // => 6

    Methods

    • Check whether two hazel buffers contain the same information.

      Parameters

      Returns boolean

      Whether or not the hazel writers are the same.

      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
    • Skip a speciied number of bytes.

      Parameters

      • bytes: number

      Returns HazelBuffer

      The writer.

      const writer = HazelWriter.alloc(12);
      writer.skip(3);
      writer.skip(2);
      writer.skip(5);

      console.log(writer.cursor); // => 10
    • Parameters

      • val: number | bigint
      • Optionalbounds: IntegerBoundary

      Returns void