Skip to content
This repository was archived by the owner on Oct 28, 2025. It is now read-only.
This repository was archived by the owner on Oct 28, 2025. It is now read-only.

Placement and name of "from{Base64,Hex}Into" #41

@anba

Description

@anba

Uint8Array.fromBase64Into and Uint8Array.fromHexInto don't match the normal naming and placement of methods:

  • Array.from, %TypedArray%.from, and the new Uint8Array.fromBase64 and Uint8Array.fromHex create new objects, indicated by the "from" prefix. from{Base64,Hex}Into don't create a new object, but instead modify existing objects. [1]
  • from{Base64,Hex}Into modify existing objects, but aren't placed on Uint8Array.prototype, but are instead methods placed on the constructor Uint8Array. [2]

I don't have concrete suggestions how to change this, but at least I wanted to open an issue, so in case the current names and placements will stay, it's documented that this was an intentional design choice.


[1] Here we could argue that the additional suffix "Into" indicates that the method doesn't create a new object.
[2] Here I'd guess the obvious explanation is that this improves discoverability when the names are similar to Uint8Array.from{Base64,Hex}.

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