Skip to content

Commit

Permalink
stream: add primordials to adapters
Browse files Browse the repository at this point in the history
PR-URL: #45511
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
  • Loading branch information
anonrig authored and danielleadams committed Jan 3, 2023
1 parent ac9a4ab commit 7984e06
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions lib/internal/webstreams/adapters.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ const {
PromiseResolve,
SafePromiseAll,
SafePromisePrototypeFinally,
TypedArrayPrototypeGetBuffer,
TypedArrayPrototypeGetByteOffset,
TypedArrayPrototypeGetByteLength,
Uint8Array,
} = primordials;

Expand Down Expand Up @@ -267,9 +270,10 @@ function newStreamWritableFromWritableStream(writableStream, options = kEmptyObj
} else {
chunk = Buffer.from(chunk, encoding);
chunk = new Uint8Array(
chunk.buffer,
chunk.byteOffset,
chunk.byteLength);
TypedArrayPrototypeGetBuffer(chunk),
TypedArrayPrototypeGetByteOffset(chunk),
TypedArrayPrototypeGetByteLength(chunk),
);
}
}

Expand Down Expand Up @@ -692,9 +696,10 @@ function newStreamDuplexFromReadableWritablePair(pair = kEmptyObject, options =
} else {
chunk = Buffer.from(chunk, encoding);
chunk = new Uint8Array(
chunk.buffer,
chunk.byteOffset,
chunk.byteLength);
TypedArrayPrototypeGetBuffer(chunk),
TypedArrayPrototypeGetByteOffset(chunk),
TypedArrayPrototypeGetByteLength(chunk),
);
}
}

Expand Down

0 comments on commit 7984e06

Please sign in to comment.