UNPKG

829 BJavaScriptView Raw
1'use strict';
2var global = require('../internals/global');
3var fails = require('../internals/fails');
4var V8 = require('../internals/engine-v8-version');
5var IS_BROWSER = require('../internals/engine-is-browser');
6var IS_DENO = require('../internals/engine-is-deno');
7var IS_NODE = require('../internals/engine-is-node');
8
9var structuredClone = global.structuredClone;
10
11module.exports = !!structuredClone && !fails(function () {
12 // prevent V8 ArrayBufferDetaching protector cell invalidation and performance degradation
13 // https://github.com/zloirock/core-js/issues/679
14 if ((IS_DENO && V8 > 92) || (IS_NODE && V8 > 94) || (IS_BROWSER && V8 > 97)) return false;
15 var buffer = new ArrayBuffer(8);
16 var clone = structuredClone(buffer, { transfer: [buffer] });
17 return buffer.byteLength !== 0 || clone.byteLength !== 8;
18});