Skip to content

Commit

Permalink
Rename function
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Aug 11, 2023
1 parent 3981884 commit bcb87e7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,15 @@ const useUint8ArrayWithOffset = chunk => new Uint8Array(chunk.buffer, chunk.byte

// `contents` is an increasingly growing `Uint8Array`.
const addArrayBufferChunk = (convertedChunk, contents, length, previousLength) => {
const newContents = hasArrayBufferResize() ? resizeArrayBufferFast(contents, length) : resizeArrayBuffer(contents, length);
const newContents = hasArrayBufferResize() ? resizeArrayBuffer(contents, length) : resizeArrayBufferSlow(contents, length);
newContents.set(convertedChunk, previousLength);
return newContents;
};

// Without `ArrayBuffer.resize()`, `contents` size is always a power of 2.
// This means its last bytes are zeroes (not stream data), which need to be
// trimmed at the end with `ArrayBuffer.slice()`.
const resizeArrayBuffer = (contents, length) => {
const resizeArrayBufferSlow = (contents, length) => {
if (length <= contents.length) {
return contents;
}
Expand All @@ -159,7 +159,7 @@ const resizeArrayBuffer = (contents, length) => {
// the stream data. It does not include extraneous zeroes to trim at the end.
// The underlying `ArrayBuffer` does allocate a number of bytes that is a power
// of 2, but those bytes are only visible after calling `ArrayBuffer.resize()`.
const resizeArrayBufferFast = (contents, length) => {
const resizeArrayBuffer = (contents, length) => {
if (length <= contents.buffer.maxByteLength) {
contents.buffer.resize(length);
return new Uint8Array(contents.buffer, 0, length);
Expand Down

0 comments on commit bcb87e7

Please sign in to comment.