Skip to content

FR: writeBufferWithLength and readBufferWithLength #36

Description

@hpx7

I'm not sure what the best name for it would be, but would be nice to have convenience methods for the following common scenario:

// write
const data = ...
const buf = new SmartBuffer()
  .writeUInt32LE(data.length)
  .writeBuffer(data)
  .toBuffer();

...

// read
const reader = SmartBuffer.from(buf);
const data = reader.readBuffer(reader.readUInt32LE());

This is useful when you're constructing complex messages with multiple buffers inside them.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions