Skip to content

[SUGGESTION]: setFromBase64/Hex offset argument #64

Open
@lifaon74

Description

@lifaon74

Hi,

I'm playing with this new api, and I thing it could be great to have an offset argument on the setFromBase64/Hex methods:

Issue: on mdn

const uint8Array = new Uint8Array(8);
// Start writing at offset 2
const result = uint8Array.subarray(2).setFromHex("cafed00d");

In my opinion, this feels sub-optimal.

Proposal:

We could mimic the .set method.

interface Uint8Array {
  setFromHex(input: string, offset?: number): { read: number; written: number; };
}
const uint8Array = new Uint8Array(8);
uint8Array.setFromHex("cafed00d", 2);

What do you think ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions