Stage 1
Classification: API Change
Human Validated: KW
Title: Limited ArrayBuffer
Authors: Jack Works
Champions: Jack Works
Last Presented: April 2021
Stage Upgrades:
Stage 1: 2021-11-11
Stage 2: NA
Stage 2.7: NA
Stage 3: NA
Stage 4: NA
Last Commit: 2022-02-07
Topics: arrays others objects
Keywords: arraybuffer limited frozen readonly
GitHub Link: https://github.com/tc39/proposal-limited-arraybuffer
GitHub Note Link: https://github.com/tc39/notes/blob/HEAD/meetings/2021-04/apr-21.md#read-only-arraybuffer-and-fixed-view-of-arraybuffer-for-stage-1
Proposal Description:
Limited ArrayBuffer
Status
Champion(s): Jack Works
Author(s): Jack Works
Stage: 1
Presentations
Problem to be resolved
All of the following are helpful to archive the minimal permission/information principle.
- Cannot make an
ArrayBuffer
read-only. - Cannot give others a read-only view to the
ArrayBuffer
and keep the read-write permission internally. - Cannot give others a view that range limited (only a small area of the whole buffer is visible).
Design goal
- Freeze the
ArrayBuffer
.- Like
Object.freeze
, there is no way back once frozen. - Any
TypedArray
/DataView
to the freezedArrayBuffer
is read-only too. - [Optional] Keep frozen when sent across Realm (HTML intergration).
- Like
- Read-only
TypedArray
/DataView
to a read-writeArrayBuffer
.- Must not be able to construct a read-write view from a read-only view.
- [Optional] Range-limited
TypedArray
/DataView
to a read-writeArrayBuffer
(CrimsonCodes0’s use case on WebAssembly).- Must not be able to construct a bigger view range from a smaller view range.
- Not adding too much complexity to the implementor.
- Have similar API design with readonly-collections.
Pros
- Minimal permission/information principle works on
ArrayBuffer
. - Embedded JS engines can represent ROMs as read-only
ArrayBuffer
.
API design
See design.md