A shared method for converting Uint8Arrays to ArrayBuffers#1115
Conversation
🦋 Changeset detectedLatest commit: d6e2b8e The changes in this PR will be included in the next version bump. This PR includes changesets to release 42 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
BundleMonFiles updated (7)
Unchanged files (126)
Total files change +423B +0.11% Final result: ✅ View report in BundleMon website ➡️ |
|
Documentation Preview: https://kit-docs-qu9x3mhdh-anza-tech.vercel.app |
| } else { | ||
| buffer = bytes.buffer; | ||
| } | ||
| return buffer.slice(bytesOffset, bytesOffset + bytesLength); |
There was a problem hiding this comment.
Should we do that thing where we don't slice if bytesOffset === 0 && bytesLength === bytes.byteLength?
There was a problem hiding this comment.
Oh crap. I did have this thought but read somewhere that the slice is just a new view into the same data. That is obviously not true because this is not a view. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/slice
There was a problem hiding this comment.
Thing to investigate: if we do this check anywhere else, it should actually be:
(bytesOffset === 0 || bytesOffset === -bytes.byteLength)
There was a problem hiding this comment.
aeaf04e to
d6e2b8e
Compare
|
Wrote some tests. Smashing this in now. |
Merge activity
|
|
Because there has been no activity on this PR for 14 days since it was merged, it has been automatically locked. Please open a new issue if it requires a follow up. |

Problem
This is going to be needed in multiple places, because there are points throughout the code (ie. where
SubtleCryptooperations appear) where we will want to cast possibleSharedArrayBufferstoArrayBuffersby cloning them as non-shared.