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

Allow resize(0) #22

Closed
Jamesernator opened this issue Jan 22, 2021 · 1 comment
Closed

Allow resize(0) #22

Jamesernator opened this issue Jan 22, 2021 · 1 comment

Comments

@Jamesernator
Copy link

The explainer currently says that a length of zero always denotes a detached buffer, however this isn't true.

const buffer = new ArrayBuffer(0) is perfectly acceptable and is not a detached buffer (in particular buffer.slice() works, whereas for a detached buffer it throws an error).

The use case of an empty array buffer (including resizable), is simply to indicate there is no data in the buffer. (Compared with detaching, which implies that the buffer is gone and no longer usable).

@syg
Copy link
Collaborator

syg commented Jan 22, 2021

Oh, interesting, thanks for the data point.

@syg syg closed this as completed in f6b9b3d Feb 23, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants