source: imaps-frontend/node_modules/core-js/internals/detach-transferable.js@ 79a0317

main
Last change on this file since 79a0317 was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 3 days ago

F4 Finalna Verzija

  • Property mode set to 100644
File size: 1.1 KB
Line 
1'use strict';
2var globalThis = require('../internals/global-this');
3var getBuiltInNodeModule = require('../internals/get-built-in-node-module');
4var PROPER_STRUCTURED_CLONE_TRANSFER = require('../internals/structured-clone-proper-transfer');
5
6var structuredClone = globalThis.structuredClone;
7var $ArrayBuffer = globalThis.ArrayBuffer;
8var $MessageChannel = globalThis.MessageChannel;
9var detach = false;
10var WorkerThreads, channel, buffer, $detach;
11
12if (PROPER_STRUCTURED_CLONE_TRANSFER) {
13 detach = function (transferable) {
14 structuredClone(transferable, { transfer: [transferable] });
15 };
16} else if ($ArrayBuffer) try {
17 if (!$MessageChannel) {
18 WorkerThreads = getBuiltInNodeModule('worker_threads');
19 if (WorkerThreads) $MessageChannel = WorkerThreads.MessageChannel;
20 }
21
22 if ($MessageChannel) {
23 channel = new $MessageChannel();
24 buffer = new $ArrayBuffer(2);
25
26 $detach = function (transferable) {
27 channel.port1.postMessage(null, [transferable]);
28 };
29
30 if (buffer.byteLength === 2) {
31 $detach(buffer);
32 if (buffer.byteLength === 0) detach = $detach;
33 }
34 }
35} catch (error) { /* empty */ }
36
37module.exports = detach;
Note: See TracBrowser for help on using the repository browser.