mirror of
https://github.com/denoland/deno.git
synced 2025-08-04 02:48:24 +00:00
feat: ArrayBuffer in structured clone transfer (#11840)
This commit is contained in:
parent
f84cd9403d
commit
5d814a4c24
8 changed files with 213 additions and 27 deletions
|
@ -362,6 +362,7 @@
|
|||
|
||||
const entries = [];
|
||||
let iter;
|
||||
let valueIsTypedArray = false;
|
||||
|
||||
switch (options.typeName) {
|
||||
case "Map":
|
||||
|
@ -376,6 +377,7 @@
|
|||
default:
|
||||
if (isTypedArray(value)) {
|
||||
iter = ArrayPrototypeEntries(value);
|
||||
valueIsTypedArray = true;
|
||||
} else {
|
||||
throw new TypeError("unreachable");
|
||||
}
|
||||
|
@ -385,7 +387,24 @@
|
|||
const next = () => {
|
||||
return iter.next();
|
||||
};
|
||||
for (const el of iter) {
|
||||
while (true) {
|
||||
let el;
|
||||
try {
|
||||
const res = iter.next();
|
||||
if (res.done) {
|
||||
break;
|
||||
}
|
||||
el = res.value;
|
||||
} catch (err) {
|
||||
if (valueIsTypedArray) {
|
||||
// TypedArray.prototype.entries doesn't throw, unless the ArrayBuffer
|
||||
// is detached. We don't want to show the exception in that case, so
|
||||
// we catch it here and pretend the ArrayBuffer has no entries (like
|
||||
// Chrome DevTools does).
|
||||
break;
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
if (entriesLength < inspectOptions.iterableLimit) {
|
||||
ArrayPrototypePush(
|
||||
entries,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue