mirror of
https://github.com/denoland/deno.git
synced 2025-09-26 12:19:12 +00:00
fix(ext/node): enable Buffer
pool for strings (#29592)
Part 1 towards enabling `parallel/test-buffer-pool-untransferable.js`
This commit is contained in:
parent
1e6aca57e8
commit
8b81644b59
6 changed files with 83 additions and 24 deletions
|
@ -39,10 +39,15 @@ const {
|
|||
Symbol,
|
||||
MathMin,
|
||||
DataViewPrototypeGetBuffer,
|
||||
DataViewPrototypeGetByteLength,
|
||||
DataViewPrototypeGetByteOffset,
|
||||
ObjectPrototypeIsPrototypeOf,
|
||||
String,
|
||||
TypedArrayPrototypeGetBuffer,
|
||||
TypedArrayPrototypeGetByteLength,
|
||||
TypedArrayPrototypeGetByteOffset,
|
||||
StringPrototypeToLowerCase,
|
||||
Uint8Array,
|
||||
} = primordials;
|
||||
const { isTypedArray } = core;
|
||||
|
||||
|
@ -84,10 +89,19 @@ function normalizeBuffer(buf: Buffer) {
|
|||
if (isBufferType(buf)) {
|
||||
return buf;
|
||||
} else {
|
||||
const isTA = isTypedArray(buf);
|
||||
return Buffer.from(
|
||||
isTypedArray(buf)
|
||||
? TypedArrayPrototypeGetBuffer(buf)
|
||||
: DataViewPrototypeGetBuffer(buf),
|
||||
new Uint8Array(
|
||||
isTA
|
||||
? TypedArrayPrototypeGetBuffer(buf)
|
||||
: DataViewPrototypeGetBuffer(buf),
|
||||
isTA
|
||||
? TypedArrayPrototypeGetByteOffset(buf)
|
||||
: DataViewPrototypeGetByteOffset(buf),
|
||||
isTA
|
||||
? TypedArrayPrototypeGetByteLength(buf)
|
||||
: DataViewPrototypeGetByteLength(buf),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue