Add lastChunkHandling ("loose", "strict", or "stop-before-partial") to base64 decoding #55360
Description
What is the problem this feature will solve?
The current array buffer JavaScript proposal includes support for lastChunkHandling ("loose", "strict", or "stop-before-partial") in addition to the standard base64 and base64url format.
https://tc39.es/proposal-arraybuffer-base64/spec/#sec-frombase64
Specifically, the following syntax is considered:
FromBase64 ( string, alphabet, lastChunkHandling [ , maxLength ] )
where alphabet is base64 or base64url and lastChunkHandling is one of the relevant values.
What is the feature you are proposing to solve the problem?
Node buffers might want to implement this feature. Currently, one can do Buffer.from(data, 'base64')
and it defaults on 'loose' but Node could add some way for the user to specify how the last chunk is handled. E.g., Buffer.from(data, 'base64+strict')
.
Note that Node currently relies on simdutf for base64 decoding and as of version 5.6.0, the simdutf library has the necessary support. Thus, the implementation would not be a significant challenge.
What alternatives have you considered?
Quite reasonably, Node could just not add this functionality.
Metadata
Assignees
Labels
Type
Projects
Status
Awaiting Triage